[connection] move call_service on Connection
This is the last step toward standalone transaction.
--- 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 #######################################################