[PEAK] Strange dispatch problem after cvs up
Jay Parlar
parlar at gmail.com
Wed Apr 20 14:21:59 EDT 2005
I was finally able to reproduce the problem with a trivial example:
>>> import dispatch
>>> class A:
... [dispatch.generic()]
... def make(self, ctrl):
... '''
... stuff
... '''
... [make_header.when('ctrl == 4')]
... def make(self, ctrl):
... print "four"
...
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "<stdin>", line 7, in A
File "c:\Python24\Lib\site-packages\dispatch\functions.py", line 690, in when
return self._decorate(cond)
File "c:\Python24\Lib\site-packages\dispatch\functions.py", line 577, in _deco
rate
cond = self.parseRule(cond,frame=frame) or cond
File "<string>", line 10, in parseRule
File "c:\Python24\Lib\site-packages\dispatch\functions.py", line 440, in parse
Rule
return self.parse(rule, frame.f_locals, frame.f_globals)
File "c:\Python24\Lib\site-packages\dispatch\functions.py", line 323, in parse
from dispatch.predicates import CriteriaBuilder
File "c:\Python24\Lib\site-packages\dispatch\predicates.py", line 722, in ?
[expressionSignature.when(
File "c:\Python24\Lib\site-packages\dispatch\predicates.py", line 722, in ?
[expressionSignature.when(
File "c:\Python24\Lib\site-packages\protocols\advice.py", line 289, in tracer
frm.f_locals[k] = callback(frm,k,v,old_locals)
File "c:\Python24\Lib\site-packages\dispatch\functions.py", line 597, in regis
terMethod
self.addMethod(cond,func)
File "c:\Python24\Lib\site-packages\dispatch\functions.py", line 559, in addMe
thod
self[signature] = function
File "c:\Python24\Lib\site-packages\dispatch\functions.py", line 421, in __set
item__
signature = strategy.Signature(
File "c:\Python24\Lib\site-packages\dispatch\functions.py", line 500, in _disp
atch_id
self.disp_indexes[disp] = criterion.node_type.make_index()
TypeError: unbound method make_index() must be called with Node instance as firs
t argument (got nothing instead)
This also failed using the regular @ decorator syntax, and with
new-style classes.
However, if I do something like:
>>> import dispatch
>>> class A:
... [dispatch.on('ctrl')]
... def make(self, ctrl):
... '''
... stuff
... '''
... [make_header.when(int)]
... def make(self, ctrl):
... print "four"
it works just fine.
Jay P.
More information about the PEAK
mailing list