Author: dmeyer
Date: Sun Feb  5 19:15:03 2006
New Revision: 1165

Modified:
   trunk/base/src/notifier/decorators.py
   trunk/base/test/decorator.py

Log:
fix bug with more than one exposed function in a class

Modified: trunk/base/src/notifier/decorators.py
==============================================================================
--- trunk/base/src/notifier/decorators.py       (original)
+++ trunk/base/src/notifier/decorators.py       Sun Feb  5 19:15:03 2006
@@ -61,31 +61,31 @@
                 # just start the timer
                 timer(func, *args, **kwargs).start(interval)
                 return True
-
+            # object to save the timer in
+            obj  = func
+            # name of the attribute in the object
+            name = '__kaa_timer_decorator'
             # Try to find out if the function is bound to an object.
             # FIXME: maybe this is bad solution, how fast is comparing
             # the func_code attributes?
-            obj = func
             if args and args[0] and hasattr(args[0], func.func_name) and \
                    newfunc.func_code == getattr(args[0], 
func.func_name).func_code:
-                obj = args[0]
+                obj  = args[0]
+                name = '%s__%s' % (name, func.func_name)
             # check current timer
-            if hasattr(obj, '__kaa_timer_decorator') and \
-                   obj.__kaa_timer_decorator.active():
+            if hasattr(obj, name) and getattr(obj, name).active():
                 if type == 'once':
                     # timer already running and not override
                     return False
                 # stop old timer
-                obj.__kaa_timer_decorator.stop()
+                getattr(obj, name).stop()
 
             # create new timer, set it to the object and start it
-            obj.__kaa_timer_decorator = timer(func, *args, **kwargs)
-            obj.__kaa_timer_decorator.start(interval)
+            setattr(obj, name, timer(func, *args, **kwargs))
+            getattr(obj, name).start(interval)
             return True
-        try:
-            newfunc.func_name = func.func_name
-        except TypeError:
-            pass
+
+        newfunc.func_name = func.func_name
         return newfunc
 
     return decorator

Modified: trunk/base/test/decorator.py
==============================================================================
--- trunk/base/test/decorator.py        (original)
+++ trunk/base/test/decorator.py        Sun Feb  5 19:15:03 2006
@@ -9,7 +9,15 @@
         if not x:
             return False
         y = x.pop(0)
-        print y
+        print '1', y
+        return True
+
+    @execute_in_timer(Timer, 0.1, 'once')
+    def poll2(self, x):
+        if not x:
+            return False
+        y = x.pop(0)
+        print '2', y
         return True
 
     @execute_in_thread('name')
@@ -39,6 +47,7 @@
     
 f = Foo()
 f.poll([0,1,2,3,4,5])
+f.poll2(['a','b','c','d','e','f'])
 
 poll([10,11,12,13,14,15])
 bla(f, 'test')


-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
_______________________________________________
Freevo-cvslog mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/freevo-cvslog

Reply via email to