On Dec 29, 2010, at 5:04 PM, Mike Bernson wrote:

> Looking at the events for instances.
> 
> The on_expire passes a list of attributes being expired but the on_refresh 
> does not have a list of attribute being refresh.
> 
> Can the list of attribute being refreshed be add to on_refresh event ?

this is planned !


> 
> 
> I am looking to move from using mapperextension to instance events.
> 
> I am using 2 methods:
>    reconstruct_instance:
>        find when a model is load for the first time
> 
>    populate_instance:
>        find when a model is refresh/loading attributes and which attributes
>        find when a model is loaded again with populate_existing
> 
> 
> looks like i can use on_load to replace reconstruct_instance.

reconstruct_instance is synonymous with on_load.  on_refresh() means something 
that was already present was matched by an incoming row and had either expired 
attributes or populate_existing.

> 
> not sure about replacing populate_instance. The doc make me think that
> on_populate_instance should not be used.

yes that event was from 0.1 and isn't very event-like, it was meant as a "put 
your own populate-the-instance-routine-here", and that's a really bad idea.  
The instance isn't necessarily yet populated when this is called.

> If this is the case then
> it would be nice if on_refresh had a list attribute being refreshed.

this is planned !

> 
> populate_instance has a flag called only_load_props that i used to tell if
> just refresh attributes or rereading record from database using 
> populate_existing.
> 
> The last issues is how to catch reread of a record using populate_existing ?

populate_existing() is the same as an expired record being populated with 
applicable rows that have come in.    So these events look the same.   The 
information would ultimately be if the QueryContext were passed through and you 
were to dig into it and look for the "populate_existing" flag.    Adding this 
would imply its available to both on_refresh() and on_load().   It's probably 
worth adding "context" to on_load() and on_refresh().


-- 
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.

Reply via email to