import blinker
from blinker import signal
class Ticket():
@classmethod
def update(cls):
pass
ticket_created = signal('CREATED')
ticket_created.connect(Ticket.update)
这段代码在 Python 2.7 上运行良好。但不适用于 Python 2.6。我得到这个踪迹:
Traceback (most recent call last):
File "btest.py", line 10, in <module>
ticket_created.connect(Ticket.update)
File "/home/gavika/env2/lib/python2.6/site-packages/blinker/base.py", line 113, in connect
receiver_ref = reference(receiver, self._cleanup_receiver)
File "/home/gavika/env2/lib/python2.6/site-packages/blinker/_utilities.py", line 134, in reference
weak = callable_reference(object, callback)
File "/home/gavika/env2/lib/python2.6/site-packages/blinker/_utilities.py", line 145, in callable_reference
return BoundMethodWeakref(target=object, on_delete=callback)
File "/home/gavika/env2/lib/python2.6/site-packages/blinker/_saferef.py", line 143, in __new__
base.__init__(target, on_delete, *arguments, **named)
File "/home/gavika/env2/lib/python2.6/site-packages/blinker/_saferef.py", line 185, in __init__
self.weak_self = weakref.ref(im_self, remove)
TypeError: cannot create weak reference to 'classobj' object
有没有办法让它在 2.6 环境中工作?