server/session.py
branchstable
changeset 2182 488099333160
parent 2100 89b825cdec74
child 2190 d9f5fd1879fc
equal deleted inserted replaced
2180:bf2e81fb52be 2182:488099333160
    81         return self
    81         return self
    82 
    82 
    83     def etype_class(self, etype):
    83     def etype_class(self, etype):
    84         """return an entity class for the given entity type"""
    84         """return an entity class for the given entity type"""
    85         return self.vreg.etype_class(etype)
    85         return self.vreg.etype_class(etype)
    86 
       
    87     def entity(self, eid):
       
    88         """return a result set for the given eid"""
       
    89         return self.eid_rset(eid).get_entity(0, 0)
       
    90 
    86 
    91     def system_sql(self, sql, args=None):
    87     def system_sql(self, sql, args=None):
    92         """return a sql cursor on the system database"""
    88         """return a sql cursor on the system database"""
    93         if not sql.split(None, 1)[0].upper() == 'SELECT':
    89         if not sql.split(None, 1)[0].upper() == 'SELECT':
    94             self.mode = 'write'
    90             self.mode = 'write'
   357             return self._threaddata.transaction_data
   353             return self._threaddata.transaction_data
   358         except AttributeError:
   354         except AttributeError:
   359             self._threaddata.transaction_data = {}
   355             self._threaddata.transaction_data = {}
   360             return self._threaddata.transaction_data
   356             return self._threaddata.transaction_data
   361 
   357 
   362     @obsolete('use direct access to session.transaction_data')
       
   363     def query_data(self, key, default=None, setdefault=False, pop=False):
       
   364         if setdefault:
       
   365             assert not pop
       
   366             return self.transaction_data.setdefault(key, default)
       
   367         if pop:
       
   368             return self.transaction_data.pop(key, default)
       
   369         else:
       
   370             return self.transaction_data.get(key, default)
       
   371 
       
   372     @property
   358     @property
   373     def pending_operations(self):
   359     def pending_operations(self):
   374         try:
   360         try:
   375             return self._threaddata.pending_operations
   361             return self._threaddata.pending_operations
   376         except AttributeError:
   362         except AttributeError:
   455                         self.critical('wrong eid %s in repository, should check database' % value)
   441                         self.critical('wrong eid %s in repository, should check database' % value)
   456                         row_descr[index] = row[index] = None
   442                         row_descr[index] = row[index] = None
   457             description.append(tuple(row_descr))
   443             description.append(tuple(row_descr))
   458         return description
   444         return description
   459 
   445 
       
   446     @obsolete('use direct access to session.transaction_data')
       
   447     def query_data(self, key, default=None, setdefault=False, pop=False):
       
   448         if setdefault:
       
   449             assert not pop
       
   450             return self.transaction_data.setdefault(key, default)
       
   451         if pop:
       
   452             return self.transaction_data.pop(key, default)
       
   453         else:
       
   454             return self.transaction_data.get(key, default)
       
   455 
       
   456     @obsolete('use entity_from_eid(eid, etype=None)')
       
   457     def entity(self, eid):
       
   458         """return a result set for the given eid"""
       
   459         return self.eid_rset(eid).get_entity(0, 0)
       
   460 
   460 
   461 
   461 class ChildSession(Session):
   462 class ChildSession(Session):
   462     """child (or internal) session are used to hijack the security system
   463     """child (or internal) session are used to hijack the security system
   463     """
   464     """
   464     cnxtype = 'inmemory'
   465     cnxtype = 'inmemory'