From 53af01c95abe622c0490b43c12439a04aa449509 Mon Sep 17 00:00:00 2001 From: Simon Poirier Date: Wed, 28 Oct 2009 06:15:15 +0000 Subject: addon test extension to check interface contraints --- (limited to 'addons/oncewrapper.py') diff --git a/addons/oncewrapper.py b/addons/oncewrapper.py index 5db3b60..9f339a4 100644 --- a/addons/oncewrapper.py +++ b/addons/oncewrapper.py @@ -26,17 +26,16 @@ class OnceWrapper(Action): action = TAddonProperty() - def __init__(self, action): + def __init__(self, action=None): Action.__init__(self) - self._called = False - self._need_undo = False - self.action = action + if action: + self.action = action def do(self): """ Do the action only on the first time """ - if not self._called: + if not hasattr(self, '_called'): self._called = True self.action.do() self._need_undo = True @@ -45,9 +44,9 @@ class OnceWrapper(Action): """ Undo the action if it's been done """ - if self._need_undo: + if hasattr(self, '_need_undo'): self.action.undo() - self._need_undo = False + del self._need_undo __action__ = { -- cgit v0.9.1