# HG changeset patch # User Thierry Florac # Date 1350633401 -7200 # Node ID 3bdaee25ec3ab527c4dcc3884cc9f0d02a39c2e9 # Parent ad0c70fceea98e403d5f191a5278a5d343833255 Change context manager to directly return ZEO connection root diff -r ad0c70fceea9 -r 3bdaee25ec3a 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: