From 9a326a33b28fb685e681bf63c63be9f820db0356 Mon Sep 17 00:00:00 2001 From: Leandro Lucarella Date: Wed, 10 Oct 2007 16:00:43 -0300 Subject: [PATCH] Raise a CommandNotFoundError if updating an object without update(). When a DictSubHandler try to update an object that doesn't have an update() method, it raises a CommandNotFoundError to emulate that the update command doesn't exist. --- pymin/services/util.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pymin/services/util.py b/pymin/services/util.py index c0371a1..3f50957 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 @@ -619,6 +620,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) -- 2.43.0