except ImportError:
import pickle
-from pymin.dispatcher import Handler, handler, HandlerError
+from pymin.dispatcher import Handler, handler, HandlerError, \
+ CommandNotFoundError
#DEBUG = False
DEBUG = True
list and show.
"""
- def __init__(self, parent, attr=None, key=None, cls=None):
+ def __init__(self, parent, attr=None, cls=None):
r"Initialize the object, see the class documentation for details."
self.parent = parent
if attr is not None:
self._dict_subhandler_attr = attr
- if key is not None:
- self._dict_subhandler_key = key
if cls is not None:
self._dict_subhandler_class = cls
@handler(u'Update an item')
def update(self, key, *args, **kwargs):
r"update(key, ...) -> None :: Update an item of the dict."
+ # TODO make it right with metaclasses, so the method is not created
+ # unless the update() method really exists.
+ if not hasattr(self._dict_subhandler_class, 'update'):
+ raise CommandNotFoundError(('update',))
if not key in self._dict():
raise ItemNotFoundError(key)
self._dict()[key].update(*args, **kwargs)