# HG changeset patch # User Adrien Di Mascio # Date 1234917909 -3600 # Node ID c0506c4a1e6cb2f1a64e888f165258347a258881 # Parent ec16f43107d3062bd38bd9f76ae3610cee654b8e fix lltrace to consider __call__ and pure functions decoration diff -r ec16f43107d3 -r c0506c4a1e6c selectors.py --- 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