[connection] move call_service on Connection
authorPierre-Yves David <pierre-yves.david@logilab.fr>
Tue, 25 Jun 2013 18:04:08 +0200
changeset 9093 e2f88df79efd
parent 9092 48d488dd3c51
child 9094 b151beea9cb6
[connection] move call_service on Connection This is the last step toward standalone transaction.
server/repository.py
server/session.py
--- a/server/repository.py	Thu Jun 27 11:21:14 2013 +0200
+++ b/server/repository.py	Tue Jun 25 18:04:08 2013 +0200
@@ -854,17 +854,9 @@
         See :class:`cubicweb.dbapi.Connection.call_service`
         and :class:`cubicweb.server.Service`
         """
+        # XXX lack a txid
         session = self._get_session(sessionid)
-        return self._call_service_with_session(session, regid, **kwargs)
-
-    def _call_service_with_session(self, session, regid, **kwargs):
-        self.info('calling service %s synchronously', regid)
-        session.set_cnxset()
-        try:
-            service = session.vreg['services'].select(regid, session, **kwargs)
-            return service.call(**kwargs)
-        finally:
-            session.free_cnxset()
+        return session._cnx.call_service(regid, **kwargs)
 
     def user_info(self, sessionid, props=None):
         """this method should be used by client to:
--- a/server/session.py	Thu Jun 27 11:21:14 2013 +0200
+++ b/server/session.py	Tue Jun 25 18:04:08 2013 +0200
@@ -1017,6 +1017,15 @@
 
     # resource accessors ######################################################
 
+    def call_service(self, regid, **kwargs):
+        self.info('calling service %s', regid)
+        self.set_cnxset()
+        try:
+            service = self.vreg['services'].select(regid, self, **kwargs)
+            return service.call(**kwargs)
+        finally:
+            self.free_cnxset()
+
     def system_sql(self, sql, args=None, rollback_on_failure=True):
         """return a sql cursor on the system database"""
         if sql.split(None, 1)[0].upper() != 'SELECT':
@@ -1400,9 +1409,7 @@
 
     # server-side service call #################################################
 
-    def call_service(self, regid, **kwargs):
-        return self.repo._call_service_with_session(self, regid,
-                                                    **kwargs)
+    call_service = cnx_meth('call_service')
 
     # request interface #######################################################