instrumentation events aren't specific to subclasses
this is documented as the behavior of instrumentation events, so we should really get this right. probably we will need to wrap incoming events inside a filter for that subclass.
from sqlalchemy import Table, Column, MetaData, Integer
from sqlalchemy.orm import mapper, configure_mappers
from sqlalchemy import event
class Foo(object):
pass
class Bar(object):
pass
@event.listens_for(Foo, "attribute_instrument")
def nope(cls, key, inst):
assert False
m = MetaData()
t = Table('t', m, Column('x', Integer, primary_key=True))
mapper(Bar, t)
configure_mappers()
Comments (5)
-
reporter -
reporter also tricky. with
#2585those are class level events that ultimately we'd like them to become mapper-instance-level, though maybe not (what if class Foo is mapped, unmapped, remapped ? arg...) Then what if Foo is dereferenced ? a plain class-level mapper stays around forever.Perhaps the event system would have target-filters built in that make use of weak referencing.
-
reporter or another approach. as we receive unmapped, uninstrumented classes, we stick them in a weak map somewhere, then as new classes are instrumented and new mappers are created, we check against that collection to add new events. lets look into this as this is how attribute and mapper events work for subclasses right now.
-
reporter - changed status to resolved
-
reporter - removed milestone
Removing milestone: 0.8.0b1 (automated comment)
- Log in to comment
the same approach can be applied to
#2585.