From f63d7dd22618af7e229885d183f482829e96b2a3 Mon Sep 17 00:00:00 2001 From: Vincent Vinet Date: Tue, 03 Mar 2009 15:53:02 +0000 Subject: Remove the Mixin Action classes. They were never meant to be. Hope they don't feel too rejected. Because they are. --- (limited to 'src/sugar/tutorius/actions.py') diff --git a/src/sugar/tutorius/actions.py b/src/sugar/tutorius/actions.py index 68ec374..34802c3 100644 --- a/src/sugar/tutorius/actions.py +++ b/src/sugar/tutorius/actions.py @@ -38,49 +38,12 @@ class Action(object): pass #Should raise NotImplemented? -class DoOnceMixin(object): - """Mixin class used to have an action be called only on the first do(). - - To use this mixin, create a new class that derives from this and from - the action you want executed only once. - - class ConcreteOnceAction(DoOnceMixin, ConcreteAction): - pass +class OnceWrapper(object): + """ + Wraps a class to perform an action once only This ConcreteActions's do() method will only be called on the first do() and the undo() will be callable after do() has been called - - Maybe it would be better off just using a wrapper class instead of this. - - But it was fun to play with. - - Did I mention the wrapper is 25 lines "south" of here? Besides, this mixin - class fails at __init__ ..... mixins... right....narwhals! - """ - def __init__(self ): - super(DoOnceMixin, self).__init__() - self._called = False - self._need_undo = False - - def do(self): - """ - Do the action only on the first time - """ - if not self._called: - self._called = True - super(DoOnceMixin, self).do() - self._need_undo = True - - def undo(self): - """ - Undo the action if it's been done - """ - if self._need_undo: - super(DoOnceMixin, self).undo() - self._need_undo = False - -class OnceWrapper(object): - """Wraps a class to perform an action once only """ def __init__(self, action): self._action = action @@ -136,7 +99,3 @@ class DialogMessage(Action): self._dialog = None - -class OnceDialogMessage(DoOnceMixin, DialogMessage): - """Broken!""" - pass -- cgit v0.9.1