[Sqlalchemy-tickets] Issue #3388: instrument_class event is being called at the wrong time in 1.0 (
Brought to you by:
zzzeek
|
From: Mike B. <iss...@bi...> - 2015-04-26 21:19:06
|
New issue 3388: instrument_class event is being called at the wrong time in 1.0 https://bitbucket.org/zzzeek/sqlalchemy/issue/3388/instrument_class-event-is-being-called-at Mike Bayer: this works in 0.9, fails in 1.0. Not really sure how this can be happening since nothing should have changed in this regard: ``` #!python from sqlalchemy import event from sqlalchemy import MetaData, Table, Column, Integer from sqlalchemy.orm import mapper def my_init(self): print("hi") @event.listens_for(mapper, "instrument_class") def instrument_class(mp, class_): print("INSTRUMENT CLASS!") class_.__init__ = my_init m = MetaData() foo = Table('foo', m, Column('id', Integer, primary_key=True)) class Foo(object): pass ``` mapper(Foo, foo) f1 = Foo() assert f1._sa_instance_state |