[repo services] set cnxset before calling the service then ensure it's freed
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Mon, 27 Feb 2012 18:15:23 +0100
changeset 8280 17c588eca3c2
parent 8277 8b173e0a617f
child 8292 6f2de09b29e8
[repo services] set cnxset before calling the service then ensure it's freed
server/repository.py
--- a/server/repository.py	Mon Feb 27 13:00:36 2012 +0100
+++ b/server/repository.py	Mon Feb 27 18:15:23 2012 +0100
@@ -887,9 +887,12 @@
         and :class:`cubicweb.server.Service`
         """
         def task():
-            session = self._get_session(sessionid)
+            session = self._get_session(sessionid, setcnxset=True)
             service = session.vreg['services'].select(regid, session, **kwargs)
-            return service.call(session, **kwargs)
+            try:
+                return service.call(session, **kwargs)
+            finally:
+                session.rollback() # free cnxset
         if async:
             self.info('calling service %s asynchronously', regid)
             self.threaded_task(task)