[service] extract session retrieval from "task" closure
The session was retrieved there because `set_cnxset` must be called in the same
thread as the code using it. We now retrieve the session beforehand and
explicitly call `set_cnxset`.
--- a/server/repository.py Thu Mar 28 15:43:23 2013 +0100
+++ b/server/repository.py Tue Apr 02 14:46:13 2013 +0200
@@ -882,10 +882,11 @@
See :class:`cubicweb.dbapi.Connection.call_service`
and :class:`cubicweb.server.Service`
"""
+ session = self._get_session(sessionid)
def task():
- session = self._get_session(sessionid, setcnxset=True)
- service = session.vreg['services'].select(regid, session, **kwargs)
+ session.set_cnxset()
try:
+ service = session.vreg['services'].select(regid, session, **kwargs)
return service.call(**kwargs)
finally:
session.rollback() # free cnxset