Page object design: wrapping a dictionary containing data
I've got a Page object that derives all its data from a dictionary, eg: { 'project_name': 'project', 'project_description': 'hello', # ... you get the idea } What's a good way for the Page object to wrap that dictionary that doesn't involve doing this: def data_name(self, ctx, data): return self.d['project_name'] def data_description(self, ctx, data): return self.d['project_description'] # and so on for every key in the dictionary I vaguely recall that the equivalent of this used to be possible in Woven: def data_project(self, ctx, data): return self.d and then that the data items were accessible by (say) stan.directive("project/project_name"). This doesn't look like its supported in Nevow. Is this correct? What alternative designs are there for something like this? -Mary
participants (7)
-
Andy Gayton
-
Donovan Preston
-
Jason Mobarak
-
Mary Gardiner
-
Matt Goodall
-
Michael Hudson
-
Tristan Seligmann