Michael Bayer wrote:
> using a temporary session is still problematic.  because the lazy  
> loading function needs to know how to create one.  in many cases,  
> thats easy, its just create_session(), but as we know in many other  
> cases, its not, if the session needs to bind to an engine, or if it  
> binds to muliple engines, etc.  i would like to keep all mapper  
> functionality completely independent of whether or not you are using  
> Tables bound to Engines or Sessions bound to Engines; the simplistic  
> version of this idea would require engine-bound tables.
> 
> im not thrilled about the alternatives, which would be a). lazy load  
> functions that have to reference the engines used to create the  
> session in the first place (increases latency, memory usage, impacts  
> pickle-ness of objects, makes great big assumptions about  
> create_session()), and b). it only works if the Mapper has a  
> contexual session, which means it doenst work in all cases, and adds  
> the latency of locating all lazy loaded objects and their children so  
> that they can be surgically removed from the contexual session after  
> they are loaded.
> 
> in any case it seems like it forces SA to use some real guesswork/ 
> assumption making/works-but-then-mysteriously-breaks-in-certain- 
> configs to make this happen, whereas the hibernate restriction of,  
> "you have to put your object back into a session somewhere for your  
> lazy loaders to work again" is absolutely clear.
> 

That makes sense. I agree, the Hibernate way is probably the right way to go (I 
knew there was a good reason for it, just never thought it through completely). 
Now I definitely see that the pre-0.2 behavior was not correct and lazy 
collections really should fail if the object has been disconnected from its 
session. Would you agree that SA should raise a clearly identifiable exception 
when trying to load a lazy relationship on a disconnected object? That would at 
least make it easy to know what went wrong when it happens.

> is it so hard to just stick those objects into some auxilliary session ?

No. After my last post I was actually thinking that's the way I would do it 
anyway. But it's definitely going to cause frustration for newcomers in the ORM 
scene (it's one of those things you just need to get used to).

~ Daniel


_______________________________________________
Sqlalchemy-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users

Reply via email to