[Checkins] SVN: z3c.sqlalchemy/trunk/src/z3c/sqlalchemy/base.py
pass _id down to the session cache
Andreas Jung
andreas at andreas-jung.com
Tue Jun 12 13:30:29 EDT 2007
Log message for revision 76642:
pass _id down to the session cache
Changed:
U z3c.sqlalchemy/trunk/src/z3c/sqlalchemy/base.py
-=-
Modified: z3c.sqlalchemy/trunk/src/z3c/sqlalchemy/base.py
===================================================================
--- z3c.sqlalchemy/trunk/src/z3c/sqlalchemy/base.py 2007-06-12 17:26:23 UTC (rev 76641)
+++ z3c.sqlalchemy/trunk/src/z3c/sqlalchemy/base.py 2007-06-12 17:30:28 UTC (rev 76642)
@@ -146,14 +146,15 @@
implements(IDataManager)
- def __init__(self, session):
+ def __init__(self, session, id):
self.session = session
+ self._id = id
self.transaction = session.create_transaction()
def abort(self, trans):
self.transaction.rollback()
self.session.clear()
- session_cache.set(last_session=None)
+ session_cache.set(**{'last_session_%s' % self._id : None})
def commit(self, trans):
pass
@@ -166,7 +167,7 @@
self.session.flush()
self.transaction.commit()
self.session.clear()
- session_cache.set(last_session=None)
+ session_cache.set(**{'last_session_%s' % self._id : None})
def tpc_finish(self, trans):
pass
@@ -174,7 +175,7 @@
def tpc_abort(self, trans):
self.transaction.rollback()
self.session.clear()
- session_cache.set(last_session=None)
+ session_cache.set(**{'last_session_%s' % self._id : None})
def sortKey(self):
return 'z3c.sqlalchemy' + str(id(self))
@@ -228,7 +229,7 @@
@property
def session(self):
- last_session, = session_cache.get('last_session')
+ last_session, = session_cache.get('last_session_%s' % self._id)
# return cached session if we are within the same transaction
# and same thread
@@ -239,10 +240,10 @@
session = sqlalchemy.create_session(self._engine)
# register a DataManager with the current transaction
- transaction.get().join(SessionDataManager(session))
+ transaction.get().join(SessionDataManager(session, self._id))
# update thread-local cache
- session_cache.set(last_session=session)
+ session_cache.set(**{'last_session_%s' % self._id : session})
# return the session
return session
More information about the Checkins
mailing list