[service] handle cnxset in the async case only
The service may be called by a session, we really do not want the call to
service to mess with the transaction state.
This does not apply to async were thread magic ensure a dedicated transaction.
--- a/server/repository.py Tue Apr 02 14:46:13 2013 +0200
+++ b/server/repository.py Tue Apr 02 15:11:21 2013 +0200
@@ -883,19 +883,20 @@
and :class:`cubicweb.server.Service`
"""
session = self._get_session(sessionid)
- def task():
- session.set_cnxset()
- try:
- service = session.vreg['services'].select(regid, session, **kwargs)
- return service.call(**kwargs)
- finally:
- session.rollback() # free cnxset
if async:
self.info('calling service %s asynchronously', regid)
+ def task():
+ session.set_cnxset()
+ try:
+ service = session.vreg['services'].select(regid, session, **kwargs)
+ return service.call(**kwargs)
+ finally:
+ session.rollback() # free cnxset
self.threaded_task(task)
else:
self.info('calling service %s synchronously', regid)
- return task()
+ service = session.vreg['services'].select(regid, session, **kwargs)
+ return service.call(**kwargs)
def user_info(self, sessionid, props=None):
"""this method should be used by client to: