-class ListSubHandler(SubHandler):
- r"""ListSubHandler(parent) -> ListSubHandler instance.
-
- This is a helper class to inherit from to automatically handle subcommands
- that operates over a list parent attribute.
-
- The list attribute to handle and the class of objects that it contains can
- be defined by calling the constructor or in a more declarative way as
- class attributes, like:
-
- class TestHandler(ListSubHandler):
- _list_subhandler_attr = 'some_list'
- _list_subhandler_class = SomeClass
-
- This way, the parent's some_list attribute (self.parent.some_list) will be
- managed automatically, providing the commands: add, update, delete, get,
- list and show. New items will be instances of SomeClass, which should
- provide a cmp operator to see if the item is on the list and an update()
- method, if it should be possible to modify it.
+class ContainerSubHandler(SubHandler):
+ r"""ContainerSubHandler(parent) -> ContainerSubHandler instance.
+
+ This is a helper class to implement ListSubHandler and DictSubHandler. You
+ should not use it directly.
+
+ The container attribute to handle and the class of objects that it
+ contains can be defined by calling the constructor or in a more declarative
+ way as class attributes, like:
+
+ class TestHandler(ContainerSubHandler):
+ _cont_subhandler_attr = 'some_cont'
+ _cont_subhandler_class = SomeClass
+
+ This way, the parent's some_cont attribute (self.parent.some_cont)
+ will be managed automatically, providing the commands: add, update,
+ delete, get and show. New items will be instances of SomeClass,
+ which should provide a cmp operator to see if the item is on the
+ container and an update() method, if it should be possible to modify
+ it. If SomeClass has an _add, _update or _delete attribute, it set
+ them to true when the item is added, updated or deleted respectively
+ (in case that it's deleted, it's not removed from the container,
+ but it's not listed either).