the default behavior is that changes to objects are logged in a session
that is local to the current thread.

this can be modified in two basic ways:  using per-object sessions, or
changing the algorithm used to get the current session.

these are now documented !  here:

http://www.sqlalchemy.org/docs/unitofwork.myt#unitofwork_advscope_object

http://www.sqlalchemy.org/docs/unitofwork.myt#unitofwork_advscope_scope


Jonathan Ellis wrote:
> I'm pretty sure that committing in a separate thread will commit objects
> modified in that thread only, since SA's unit-of-work is thread-local.
>
> Perhaps we can suggest an alternative if you give more info on what you're
> trying to accomplish.
>
> On 3/28/06, Koen Bok <[EMAIL PROTECTED]> wrote:
>>
>> Hmm I was too soon. This still does not work. No errors, the the db just
>> does not get updated...
>> This works perfect, but no threads...
>>
>> def commit_(self): objectstore.commit()
>>
>>
>> On 29-mrt-2006, at 1:24, Jonathan Ellis wrote:
>>
>> Since you don't say what your error is, I will just show how to make
>> your
>> code more like Python and less like Java. :)
>>
>> th = threading.Thread(target=objectsore.commit, name='updating
>> database')
>> th.start()
>>
>> That's it!
>>
>> (And you can use threading.enumerate if you need a list of threads...)
>>
>> On 3/28/06, Koen Bok <[EMAIL PROTECTED]> wrote:
>> >
>> > Hi I would like to wrap a thread around objectstore.commit () I could
>> > not get it to work.
>> > What am I doing wrong?
>> > class Controller(Object):
>> >
>> > threads = []
>> >  def commit_(self):
>> > t = CommitChanges(objectstore)
>> > self.threads.append(t)
>> >
>> > class CommitChanges(Thread):
>> > def __init__ (self, objectstore):
>> > Thread.__init__(self)
>> > self.description = "Updating Database"
>> > self.objectstore = objectstore
>> > self.start()
>> >
>> >  def run(self):
>> > self.objectstore.commit()
>> >
>>
>>
>>
>> --
>> Jonathan Ellis
>> http://spyced.blogspot.com
>>
>>
>>
>
>
> --
> Jonathan Ellis
> http://spyced.blogspot.com
>



-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
Sqlalchemy-users mailing list
Sqlalchemy-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users

Reply via email to