equal
deleted
inserted
replaced
173 def close(self): |
173 def close(self): |
174 if self._open: |
174 if self._open: |
175 self.__exit__(None, None, None) |
175 self.__exit__(None, None, None) |
176 |
176 |
177 def __repr__(self): |
177 def __repr__(self): |
178 if self.anonymous_connection: |
178 # XXX we probably want to reference the user of the session here |
|
179 if self._open is None: |
|
180 return '<ClientConnection (not open yet)>' |
|
181 elif not self._open: |
|
182 return '<ClientConnection (closed)>' |
|
183 elif self.anonymous_connection: |
179 return '<ClientConnection %s (anonymous)>' % self._cnx.connectionid |
184 return '<ClientConnection %s (anonymous)>' % self._cnx.connectionid |
180 return '<ClientConnection %s>' % self._cnx.connectionid |
185 else: |
|
186 return '<ClientConnection %s>' % self._cnx.connectionid |
181 # end silly BC |
187 # end silly BC |
182 |
188 |
183 @property |
189 @property |
184 @contextmanager |
190 @contextmanager |
185 def _srv_cnx(self): |
191 def _srv_cnx(self): |
186 """ensure that the session is locked to the right transaction |
192 """ensure that the session is locked to the right transaction |
187 |
193 |
188 TRANSITIONAL PURPOSE, This will be dropped once we use standalone |
194 TRANSITIONAL PURPOSE, This will be dropped once we use standalone |
189 session object""" |
195 session object""" |
190 if not self._open: |
196 if not self._open: |
191 raise ProgrammingError('Closed connection %s' % self._cnxid) |
197 raise ProgrammingError('Closed connection') |
192 yield self._cnx |
198 yield self._cnx |
193 |
199 |
194 # Main Connection purpose in life ######################################### |
200 # Main Connection purpose in life ######################################### |
195 |
201 |
196 call_service = _srv_cnx_func('call_service') |
202 call_service = _srv_cnx_func('call_service') |