[strongwind] Optional logging for magically bound actions.



commit 34736b997b18a1a7640a83b5990cf65942142ee4
Author: Brian G. Merrell <bgmerrell novell com>
Date:   Fri May 8 10:10:33 2009 -0600

    Optional logging for magically bound actions.
    
    Enable the logging of magically bound actions a non-default
    option.  Add a comment explaining that this should usually not be
    used.  Closes: bgo#581770.
---
 strongwind/accessibles.py |   15 +++++++++++----
 1 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/strongwind/accessibles.py b/strongwind/accessibles.py
index e1d3e80..a34eb55 100644
--- a/strongwind/accessibles.py
+++ b/strongwind/accessibles.py
@@ -281,15 +281,22 @@ class Accessible(object):
                 iaction = self._accessible.queryAction()
                 for i in xrange(iaction.nActions):
                     if utils.toVarName(iaction.getName(i)) == attr:
-                        def doActionMethod():
+                        # For most applications, you should not pass log=True
+                        # into this method.  If you want automatic logging, you
+                        # probably want to extend the Accessible class and add
+                        # logging in a widget-specific class.  For an example,
+                        # see the click() method in the Button class.
+                        def doActionMethod(log=False):
                             def sensitive():
                                 return self.sensitive
-    
+
                             if not utils.retryUntilTrue(sensitive):
                                 raise errors.NotSensitiveError
-    
+                            if log:
+                                procedurelogger.action('Perform "%s" action for %s.' % (iaction.getName(i), self))
+
                             iaction.doAction(i)
-    
+
                         return doActionMethod
             except NotImplementedError:
                 # the accessible doesn't even implement the action interface, so it has no actions.  don't do any magic bindings



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]