X-Git-Url: https://git.llucax.com/software/pymin.git/blobdiff_plain/b386d5537adb61f101a6fc82ca01e13de5b7b15f..411e573917552a233a9f9752b511396e141c1265:/pymin/services/util.py diff --git a/pymin/services/util.py b/pymin/services/util.py index c0371a1..bfdba1c 100644 --- a/pymin/services/util.py +++ b/pymin/services/util.py @@ -9,7 +9,8 @@ try: except ImportError: import pickle -from pymin.dispatcher import Handler, handler, HandlerError +from pymin.dispatcher import Handler, handler, HandlerError, \ + CommandNotFoundError #DEBUG = False DEBUG = True @@ -595,13 +596,11 @@ class DictSubHandler(SubHandler): 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 @@ -619,6 +618,10 @@ class DictSubHandler(SubHandler): @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)