On Jan 14, 2009, at 3:01 PM, koranthala wrote:

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

it seems more like the general approach of your application might need  
adjustment.   I dont know what it means in your app to "move an object  
to another thread".  If there is just a general pool of objects that  
are used by any particular thread, each thread should acquire an  
object from the pool using a single method which takes a thread-bound  
Session,  merges the requested object into the session, and returns it  
the merged copy.   There should be no boilerplate and instead should  
be appropriate abstractions in place such that non-threadsafe data  
structures are not shared between threads concurrently.


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