0
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 環境で動作させる方法はありますか?

4

1 に答える 1