On Jul 11, 2010, at 9:56 AM, Nikolaj wrote:
> Ah, it's pretty clear why this happens in Mapper.__init__: > > self._configure_extensions() > self._configure_class_instrumentation() > self._configure_properties() > > Should MapperExtensions that want to extend properties mess with > mapper._init_properties instead? for a recipe that adds AttributeExtensions in a generic way, see the example examples/custom_attributes/listen_for_events.py . You can install the __sa_instrumentation_manager__ attribute in the MapperExtension.instrument_class step if you prefer. > > On Jul 11, 2:49 pm, Nikolaj <nik....@gmail.com> wrote: >> I was trying to add an AttributeExtension to a property from my >> MapperExtension but I get this error when trying to access the >> property: >> >> AttributeError: 'Mapper' object has no attribute '_props' >> >> Here's a test case: >> >> from sqlalchemy import create_engine, Column >> from sqlalchemy.ext.declarative import declarative_base >> from sqlalchemy.types import Integer, String >> from sqlalchemy.orm import scoped_session, sessionmaker, deferred >> from sqlalchemy.orm.interfaces import MapperExtension >> >> engine = create_engine('sqlite:///:memory:', echo=True) >> Base = declarative_base(bind=engine) >> >> class MyExtension(MapperExtension): >> def __init__(self, property): >> self.property = property >> >> def instrument_class(self, mapper, class_): >> property = mapper.get_property(self.property) >> print property >> >> class Item(Base): >> __tablename__ = 'items' >> __mapper_args__ = {'extension': MyExtension('name')} >> >> id = Column(Integer, primary_key=True) >> name = deferred(Column(String)) > > -- > You received this message because you are subscribed to the Google Groups > "sqlalchemy" group. > To post to this group, send email to sqlalch...@googlegroups.com. > To unsubscribe from this group, send email to > sqlalchemy+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/sqlalchemy?hl=en. > -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalch...@googlegroups.com. To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.