server/session.py
changeset 9086 1084843ab2cb
parent 9085 af6085c9ac69
child 9087 dd26b4f95f90
equal deleted inserted replaced
9085:af6085c9ac69 9086:1084843ab2cb
   427         self.ctx_count = 0
   427         self.ctx_count = 0
   428 
   428 
   429         #: server.Repository object
   429         #: server.Repository object
   430         self.repo = session.repo
   430         self.repo = session.repo
   431         self.vreg = self.repo.vreg
   431         self.vreg = self.repo.vreg
       
   432         self._execute = self.repo.querier.execute
   432 
   433 
   433         # other session utility
   434         # other session utility
   434         self.user = session.user # XXX migrate to self._set_user when
   435         self.user = session.user # XXX migrate to self._set_user when
   435         self.lang = session.lang # Connection gain execute
   436         self.lang = session.lang # Connection gain execute
   436         self.execute = session.execute # temporary hack until all necessary
   437 
   437                                        # function have been migrated. Most of
       
   438                                        # those function requires an execute
       
   439                                        # method and execute requires them too.
       
   440 
   438 
   441         #: connection handling mode
   439         #: connection handling mode
   442         self.mode = session.default_mode
   440         self.mode = session.default_mode
   443         #: connection set used to execute queries on sources
   441         #: connection set used to execute queries on sources
   444         self._cnxset = None
   442         self._cnxset = None
   876 
   874 
   877     def source_from_eid(self, eid):
   875     def source_from_eid(self, eid):
   878         """return the source where the entity with id <eid> is located"""
   876         """return the source where the entity with id <eid> is located"""
   879         return self.repo.source_from_eid(eid, self)
   877         return self.repo.source_from_eid(eid, self)
   880 
   878 
       
   879     # core method #############################################################
       
   880 
       
   881     def execute(self, rql, kwargs=None, eid_key=None, build_descr=True):
       
   882         """db-api like method directly linked to the querier execute method.
       
   883 
       
   884         See :meth:`cubicweb.dbapi.Cursor.execute` documentation.
       
   885         """
       
   886         if eid_key is not None:
       
   887             warn('[3.8] eid_key is deprecated, you can safely remove this argument',
       
   888                  DeprecationWarning, stacklevel=2)
       
   889         rset = self._execute(self, rql, kwargs, build_descr)
       
   890         rset.req = self
       
   891         return rset
       
   892 
   881     # resource accessors ######################################################
   893     # resource accessors ######################################################
   882 
   894 
   883     def system_sql(self, sql, args=None, rollback_on_failure=True):
   895     def system_sql(self, sql, args=None, rollback_on_failure=True):
   884         """return a sql cursor on the system database"""
   896         """return a sql cursor on the system database"""
   885         if sql.split(None, 1)[0].upper() != 'SELECT':
   897         if sql.split(None, 1)[0].upper() != 'SELECT':
  1283     source_defs = cnx_meth('source_defs')
  1295     source_defs = cnx_meth('source_defs')
  1284     describe = cnx_meth('describe')
  1296     describe = cnx_meth('describe')
  1285     source_from_eid = cnx_meth('source_from_eid')
  1297     source_from_eid = cnx_meth('source_from_eid')
  1286 
  1298 
  1287 
  1299 
  1288     def execute(self, rql, kwargs=None, eid_key=None, build_descr=True):
  1300     def execute(self, *args, **kwargs):
  1289         """db-api like method directly linked to the querier execute method.
  1301         """db-api like method directly linked to the querier execute method.
  1290 
  1302 
  1291         See :meth:`cubicweb.dbapi.Cursor.execute` documentation.
  1303         See :meth:`cubicweb.dbapi.Cursor.execute` documentation.
  1292         """
  1304         """
  1293         if eid_key is not None:
       
  1294             warn('[3.8] eid_key is deprecated, you can safely remove this argument',
       
  1295                  DeprecationWarning, stacklevel=2)
       
  1296         self._timestamp.touch() # update timestamp
  1305         self._timestamp.touch() # update timestamp
  1297         rset = self._execute(self, rql, kwargs, build_descr)
  1306         rset = self._cnx.execute(*args, **kwargs)
  1298         rset.req = self
  1307         rset.req = self
  1299         return rset
  1308         return rset
  1300 
  1309 
  1301     def close_cnx(self, cnxid):
  1310     def close_cnx(self, cnxid):
  1302         cnx = self._cnxs.get(cnxid, None)
  1311         cnx = self._cnxs.get(cnxid, None)