The load() event would also capture if it were subqueryload()ed, right? And overriding Query.__iter__ wouldn't catch the cases where the scalar is a "use_get" lookup that was already in session.identity_map... No good way to intercept attributes.set_committed() for that, is there?
On Fri, Oct 28, 2016 at 11:21 AM, mike bayer <mike...@zzzcomputing.com> wrote: > > > On 10/28/2016 10:48 AM, Kent wrote: > >> @validates and 'set' attribute events will only fire when the /user/ >> sets a property (setattr), not when initially loaded by the orm. >> >> Is there a way to intercept (for inspection) a scalar relationship >> property instance when it is loaded? I don't think the 'load' event >> will work because I won't know if the current instance is being loaded >> in the context of setting an instrumented attribute. >> >> For example: >> >> If I have a parent object, I want to know when parent.childobj is >> populated by the orm framework (whether on a lazy load or joined load). >> >> Is that possible? >> >> Thanks in advance! >> > > based on the laws of twos, being that any random issue that has never been > asked ever for ten years will suddenly be asked for twice within two days, > the answer is no! the event proposed would be collection_populate, at the > same time we'd add scalar_populate, see https://groups.google.com/d/ms > g/sqlalchemy/IfuUwUgKwW0/5ZgPmpAvBAAJ . > > Interim solution is to subclass Query and override __iter__. The load() > event will get you eagerly-loaded attributes though, set it on "parent"'s > class and then inspect "childobj". > > > > > >> -- >> SQLAlchemy - >> The Python SQL Toolkit and Object Relational Mapper >> >> http://www.sqlalchemy.org/ >> >> To post example code, please provide an MCVE: Minimal, Complete, and >> Verifiable Example. See http://stackoverflow.com/help/mcve for a full >> description. >> --- >> 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 sqlalchemy+unsubscr...@googlegroups.com >> <mailto:sqlalchemy+unsubscr...@googlegroups.com>. >> To post to this group, send email to sqlalchemy@googlegroups.com >> <mailto:sqlalchemy@googlegroups.com>. >> Visit this group at https://groups.google.com/group/sqlalchemy. >> For more options, visit https://groups.google.com/d/optout. >> > > -- > SQLAlchemy - The Python SQL Toolkit and Object Relational Mapper > > http://www.sqlalchemy.org/ > > To post example code, please provide an MCVE: Minimal, Complete, and > Verifiable Example. See http://stackoverflow.com/help/mcve for a full > description. > --- You received this message because you are subscribed to a topic in the > Google Groups "sqlalchemy" group. > To unsubscribe from this topic, visit https://groups.google.com/d/to > pic/sqlalchemy/5cB4T37sWOk/unsubscribe. > To unsubscribe from this group and all its topics, send an email to > sqlalchemy+unsubscr...@googlegroups.com. > To post to this group, send email to sqlalchemy@googlegroups.com. > Visit this group at https://groups.google.com/group/sqlalchemy. > For more options, visit https://groups.google.com/d/optout. > -- SQLAlchemy - The Python SQL Toolkit and Object Relational Mapper http://www.sqlalchemy.org/ To post example code, please provide an MCVE: Minimal, Complete, and Verifiable Example. See http://stackoverflow.com/help/mcve for a full description. --- 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 sqlalchemy+unsubscr...@googlegroups.com. To post to this group, send email to sqlalchemy@googlegroups.com. Visit this group at https://groups.google.com/group/sqlalchemy. For more options, visit https://groups.google.com/d/optout.