equal
deleted
inserted
replaced
39 |
39 |
40 # import local packages |
40 # import local packages |
41 |
41 |
42 |
42 |
43 class ZEOConnectionInfo(object): |
43 class ZEOConnectionInfo(object): |
44 """ZEO connection info""" |
44 """ZEO connection info |
|
45 |
|
46 Provides a context manager which directly returns |
|
47 ZEO connection root |
|
48 """ |
45 |
49 |
46 implements(IZEOConnection) |
50 implements(IZEOConnection) |
47 |
51 |
48 _storage = None |
52 _storage = None |
49 _db = None |
53 _db = None |
85 |
89 |
86 @property |
90 @property |
87 def connection(self): |
91 def connection(self): |
88 return self._connection |
92 return self._connection |
89 |
93 |
|
94 # Context management methods |
90 def __enter__(self): |
95 def __enter__(self): |
91 self._storage, self._db = self.getConnection(get_storage=True) |
96 self._storage, self._db = self.getConnection(get_storage=True) |
92 self._connection = self._db.open() |
97 self._connection = self._db.open() |
93 return self |
98 return self._connection.root() |
94 |
99 |
95 def __exit__(self, exc_type, exc_value, traceback): |
100 def __exit__(self, exc_type, exc_value, traceback): |
96 if self._connection is not None: |
101 if self._connection is not None: |
97 self._connection.close() |
102 self._connection.close() |
98 if self._storage is not None: |
103 if self._storage is not None: |