selectors.py
branchtls-sprint
changeset 752 c0506c4a1e6c
parent 737 2494e85319fe
child 759 e044f28372bd
--- a/selectors.py	Wed Feb 18 01:42:11 2009 +0100
+++ b/selectors.py	Wed Feb 18 01:45:09 2009 +0100
@@ -67,12 +67,19 @@
     if CubicWebConfiguration.mode == 'installed':
         return selector
     def traced(cls, *args, **kwargs):
-        selname = cls.__class__.__name__
-        oid = args[0].id
+        # /!\ lltrace decorates pure function or __call__ method, this
+        #     means argument order may be different
+        if isinstance(cls, Selector):
+            selname = cls.__class__.__name__
+            vobj = args[0]
+        else:
+            selname = selector.__name__
+            vobj = cls
+        oid = vobj.id
         ret = selector(cls, *args, **kwargs)
         if TRACED_OIDS == 'all' or oid in TRACED_OIDS:
             #SELECTOR_LOGGER.warning('selector %s returned %s for %s', selname, ret, cls)
-            print 'selector %s returned %s for %s' % (selname, ret, args[0])
+            print 'selector %s returned %s for %s' % (selname, ret, vobj)
         return ret
     traced.__name__ = selector.__name__
     return traced