Change context manager to directly return ZEO connection root ZTK-1.1
authorThierry Florac <tflorac@ulthar.net>
Fri, 19 Oct 2012 09:56:41 +0200
branchZTK-1.1
changeset 181 3bdaee25ec3a
parent 180 ad0c70fceea9
child 182 207ef3d0e871
Change context manager to directly return ZEO connection root
src/ztfy/utils/zodb.py
--- a/src/ztfy/utils/zodb.py	Thu Oct 18 23:44:25 2012 +0200
+++ b/src/ztfy/utils/zodb.py	Fri Oct 19 09:56:41 2012 +0200
@@ -41,7 +41,11 @@
 
 
 class ZEOConnectionInfo(object):
-    """ZEO connection info"""
+    """ZEO connection info
+    
+    Provides a context manager which directly returns
+    ZEO connection root
+    """
 
     implements(IZEOConnection)
 
@@ -87,10 +91,11 @@
     def connection(self):
         return self._connection
 
+    # Context management methods
     def __enter__(self):
         self._storage, self._db = self.getConnection(get_storage=True)
         self._connection = self._db.open()
-        return self
+        return self._connection.root()
 
     def __exit__(self, exc_type, exc_value, traceback):
         if self._connection is not None: