I was going to look at some sort of "walk and trigger" but SQLA is elegant 
enough that I suspected I was either missing a function that already did 
this, or was fighting against the design philosophy.  Sounds like the 
latter... :)

My background gives "detached" a less ephemeral flavour, especially in a 
long-persisting rather than web app - this was sort of "configuration" 
stuff that was loaded and read-only referenced.  I'm sort of recreating a 
legacy system and designing on the fly, and hadn't quite resolved whether 
the loading session was going to remain open, and the bit that loaded the 
stuff didn't have a lazy/eager option.  I'll have no problem in this case 
to rejigger to eager-load at query time, or even make the relationships 
eager.  Thanks for the feedback.

On Thursday, January 24, 2013 2:54:14 PM UTC-4, YKdvd wrote:
>
> If I have an instance "MyInstance" with an attribute "itsLazyAttribute" 
> from a relationship, where everything is defined and queried with lazy 
> loading, then the attribute is lazily loaded, and only filled in when I 
> access it (perhaps, x=len(MyInstance.itsLazyAttribute).   But if not 
> accessed before the instance is detached (session closed, or expunge 
> called) then the attribute will be unavailable, and trigger a 
> DetachedInstanceError (not bound, lazy load operation cannot proceed).
>
> All fine, but is there any way to automatically trip all the lazy triggers 
> before detaching an instance?  Something like a 
> "session.fullyLoad(MyInstance)" type of call?  I couldn't seem to see 
> anything that would do this.  I can redo things to do an eager query, but I 
> was wondering if I was missing something?
>

-- 
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/-/HP2o7w4BAHsJ.
To post to this group, send email to sqlalchemy@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