blinker在Python 2.6中不起作用

时间:2015-02-11 15:21:37

标签: python python-2.7 python-2.6 blinker

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环境下工作?

1 个答案:

答案 0 :(得分:0)

是的,新风格的课程就是答案。

class Ticket(object):
    ...

解决问题。