[Zope] use & threadsafety of MySQLdb in Zope if not using DA?
kapil thangavelu
k_vertigo@yahoo.com
Tue, 9 Oct 2001 03:12:15 -0700
On Monday 08 October 2001 11:07 am, sean.upton@uniontrib.com wrote:
> I guess what I am trying to figure out, is how I would have non-persistent
> connection objects instantiated for each thread inside Zope upon Zope
> startup within my product code. I'm not even sure where to start, or if
> I'm going about this the wrong way; I would prefer not to have to rewrite
> my data API classes to work with a DA... thoughts?
this is laced with pitfalls since its very app centric to your application.
but you might want to give this tss/tls (thread local/specific storage) i
made for something similiar a try.
/Members/k_vertigo
and try something like
myfolder
def __init__(self, id, title)
self.tssdb = ThreadLocalStorage()
def getFooObject():
db = self._getDb()
db.getMyObjects(type='foo')
def _getDb():
db = self.tssdb.get(None)
if not db:
db = self._open_connection()
self.tssdb.set(db)
return db
def open_connect()
basically the idea was to create in memory objects that were not tied to the
persistent machinery but didn't have to deal with the extra overhead of
locking by keeping per thread copies using get_ident as an accessor.
cheers
kapil