On Jan 14, 11:05 pm, Michael Bayer <mike...@zzzcomputing.com> wrote:
> On Jan 14, 2009, at 12:58 PM, koranthala wrote:
>
>
>
> > Hi,
> >   I moved my application from 0.4 to 0.5 and now I am finding that it
> > is not working -  the error is ->
> > sqlalchemy.exc.UnboundExecutionError: Instance <Data at 0x1357110> is
> > not bound to a Session; attribute refresh operation cannot proceed
>
> >   I read through other mail chains and it looks like removal of
> > get_session()  method on Mapper is the reason for this.
> >   I actually take objects from one session to pass it to other
> > threads where the data is modified and saved. So, I cannot keep the
> > session open across threads (at least not without introducing kludgy
> > code).
>
> >   Is there any way of handling this - should I go back to 0.4?
>
> get_session() created implicit behavior of placing an object in a  
> session when none was available, so your application could be  
> surprised to find an object bound to a certain session, which could  
> later cause thread-unsafe access if the object were moved to yet  
> another thread but not removed from the previous session.   so take  
> your existing logic which removes the object from one session and  
> passes to a new thread to also add() (or merge()) the object to the  
> session corresponding to that thread.   your code will be better off  
> for its explicitness in this area.

I understood your point and tried updating my code as mentioned.
My code is a medium complex one - ~2K lines
A problem that I see is that since I take the object and use it at
many (~20) places, every single place I have to have a code like -
                m = session.merge(o)
                self.data[i] = m
which is added.

This seems very broilerplate - and there is no easy way to avoid it -
without writing a get_session myself - or having a separate object for
it.
How is it handled in other projects?
I would be very thankful if someone can help me out here.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
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