Re: [SQLObject] Re: Preparing for 0.6.1
SQLObject is a Python ORM.
Brought to you by:
ianbicking,
phd
From: Ian B. <ia...@co...> - 2004-12-31 19:09:34
|
Luke Opperman wrote: > Quoting Oleg Broytmann <ph...@ph...>: > >> On Fri, Dec 31, 2004 at 11:05:41AM -0200, Carlos Ribeiro wrote: >> >>> > conn = connectionForURI("...") >>> > if connection.supportTransactions: >>> > conn = conn.transaction() >>> > >>> > class Person(SQLObject): >>> > _connection = conn >>> >> Neither. You can call conn.begin(), conn.commit() and conn.rollback() >> at your will. After calling conn.rollback() you have to call >> conn.begin(). That's simple. > > > Am I correct in thinking this is unusable in a multi-threaded > environment, like > Webware? The Person class shares one underlying connection to the database > (pool is bypassed by Transaction), so if I have two interleaved requests > to an > UpdateUser process (whether for different user records or not) they will > both > try to begin(), and when one commits the other's changes up to that > point go > along, or a rollback in one ends the transaction for the other? It's compatible with threads, you just have to pass the connection in anytime it might be ambiguous what transaction you are working in (i.e., whenever you are dealing with class methods). Though I'm curious what people do in Zope 3, if there's anything special in sqlo... there transactions are often per-thread (which is actually a lot more convenient, since you don't have to pass the connection around, and usually what you really want anyway). -- Ian Bicking / ia...@co... / http://blog.ianbicking.org |