It doesn't appear that the method decorated by @orm.reconstructor is called on objects retrieved/loaded as relationships.
Not my desired behavior, but I guess it is consistent with the docs: "When instances are loaded during a Query operation as in query(MyMappedClass).one(), init_on_load is called." So if I need it to be executed in a relationship-loading situation, what's the best way to go about it? Thanks. — RM On Mon, Jan 7, 2013 at 3:36 AM, Ryan McKillen <[email protected]>wrote: > Worked like a charm. Thanks. > > — RM > > > On Mon, Jan 7, 2013 at 6:26 PM, Michael van Tellingen < > [email protected]> wrote: > >> See >> http://docs.sqlalchemy.org/en/latest/orm/mapper_config.html#constructors-and-object-initialization >> >> >> >> On Mon, Jan 7, 2013 at 4:47 AM, RM <[email protected]> wrote: >> > I have a class which inherits from Base. My class has a metaclass which >> > inherits from DeclarativeMeta. Among other things, the metaclass adds an >> > __init__ method to the class dictionary. When I instantiate an instance >> of >> > my class directly, my __init__ method is invoked, but if I use the ORM >> to >> > retrieve an instance, my __init__ method is not invoked. >> > >> > A metaclass serves better than a mixin for what I am trying to >> accomplish. >> > However, I did experiment with a mixin and saw the same behavior as >> > described above. >> > >> > Any ideas? Many thanks. >> > >> > -- >> > You received this message because you are subscribed to the Google >> Groups >> > "sqlalchemy" group. >> > To view this discussion on the web visit >> > https://groups.google.com/d/msg/sqlalchemy/-/oDj_bHNvP7EJ. >> > To post to this group, send email to [email protected]. >> > To unsubscribe from this group, send email to >> > [email protected]. >> > 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 [email protected]. >> To unsubscribe from this group, send email to >> [email protected]. >> 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 unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/sqlalchemy?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
