[Checkins] SVN: Product.ZSQLAlchemy/trunk/ proof-of-concept version
working :-)
Andreas Jung
andreas at andreas-jung.com
Thu Feb 1 06:37:41 EST 2007
Log message for revision 72290:
proof-of-concept version working :-)
Changed:
UU Product.ZSQLAlchemy/trunk/ZSQLAlchemy.py
_U Product.ZSQLAlchemy/trunk/__init__.py
-=-
Modified: Product.ZSQLAlchemy/trunk/ZSQLAlchemy.py
===================================================================
--- Product.ZSQLAlchemy/trunk/ZSQLAlchemy.py 2007-02-01 11:21:10 UTC (rev 72289)
+++ Product.ZSQLAlchemy/trunk/ZSQLAlchemy.py 2007-02-01 11:37:40 UTC (rev 72290)
@@ -2,30 +2,46 @@
"""
ZSQLAlchemy
-$Id: TextIndexNG3.py 1754 2007-01-27 10:38:25Z ajung $
+$Id$
"""
from Globals import InitializeClass
+from Shared.DC.ZRDB.TM import TM
from OFS.SimpleItem import SimpleItem
from AccessControl import ClassSecurityInfo
from OFS.PropertyManager import PropertyManager
from Products.PageTemplates.PageTemplateFile import PageTemplateFile
-
import sqlalchemy
import psycopg2 as psycopg
psycopg = sqlalchemy.pool.manage(psycopg)
-class SessionProxy(object):
+class SessionProxy(object, TM):
security = ClassSecurityInfo()
def __init__(self, engine):
self._engine = engine
+ self._session = sqlalchemy.create_session(bind_to=engine)
+ self._register() # register with TM
+ def _finish(self):
+ """ commit transaction """
+ if self._session is None:
+ raise RuntimeError('_session is None. This should not happen :-)')
+
+ self._session.flush()
+ self._session = None
+
+ def _abort(self):
+ """ abort transaction """
+ # Nothing to do here since SQLAlchemy starts the transaction with the
+ # current session only when calling its flush() method
+
+
security.declarePublic('getEngine')
def getEngine(self):
""" return the engine """
@@ -68,7 +84,6 @@
user=self.username,
password=self.password,
host=self.hostname)
-
return db
Property changes on: Product.ZSQLAlchemy/trunk/ZSQLAlchemy.py
___________________________________________________________________
Name: svn:keywords
+ Date Id
Property changes on: Product.ZSQLAlchemy/trunk/__init__.py
___________________________________________________________________
Name: svn:keywords
+ Date Id
More information about the Checkins
mailing list