[repoapi] make ClientConnection.__enter__ return self
authorPierre-Yves David <pierre-yves.david@logilab.fr>
Thu, 27 Jun 2013 15:13:47 +0200
changeset 9116 57387c6482e5
parent 9115 fcc732a9d9ac
child 9117 e25c5abc667c
[repoapi] make ClientConnection.__enter__ return self This allow the standard idiom:: with repoapi.connect(repo, login='babar', passwork='elephant') as cnx: cnx.execute(…)
repoapi.py
--- a/repoapi.py	Thu Jun 27 18:16:06 2013 +0200
+++ b/repoapi.py	Thu Jun 27 15:13:47 2013 +0200
@@ -162,6 +162,7 @@
         self._cnx = self._session.new_cnx()
         self._cnx.__enter__()
         self._cnx.ctx_count += 1
+        return self
 
     def __exit__(self, exc_type, exc_val, exc_tb):
         self._open = False