* deprecate session.entity method stable
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Mon, 29 Jun 2009 16:06:48 +0200
branchstable
changeset 2188 3a57c8173290
parent 2164 e3aeb6e6c3bb
child 2189 08c66a83c3ca
* deprecate session.entity method * add debug message on rollback end to avoid having simply "begin rollback" in the log
server/session.py
--- a/server/session.py	Thu Jun 25 08:26:25 2009 +0200
+++ b/server/session.py	Mon Jun 29 16:06:48 2009 +0200
@@ -84,10 +84,6 @@
         """return an entity class for the given entity type"""
         return self.vreg.etype_class(etype)
 
-    def entity(self, eid):
-        """return a result set for the given eid"""
-        return self.eid_rset(eid).get_entity(0, 0)
-
     def system_sql(self, sql, args=None):
         """return a sql cursor on the system database"""
         if not sql.split(None, 1)[0].upper() == 'SELECT':
@@ -321,6 +317,7 @@
                     self.critical('rollback error', exc_info=sys.exc_info())
                     continue
             self.pool.rollback()
+            self.debug('rollback for session %s done', self.id)
         finally:
             self._touch()
             self.pending_operations[:] = []
@@ -359,16 +356,6 @@
             self._threaddata.transaction_data = {}
             return self._threaddata.transaction_data
 
-    @obsolete('use direct access to session.transaction_data')
-    def query_data(self, key, default=None, setdefault=False, pop=False):
-        if setdefault:
-            assert not pop
-            return self.transaction_data.setdefault(key, default)
-        if pop:
-            return self.transaction_data.pop(key, default)
-        else:
-            return self.transaction_data.get(key, default)
-
     @property
     def pending_operations(self):
         try:
@@ -457,6 +444,21 @@
             description.append(tuple(row_descr))
         return description
 
+    @obsolete('use direct access to session.transaction_data')
+    def query_data(self, key, default=None, setdefault=False, pop=False):
+        if setdefault:
+            assert not pop
+            return self.transaction_data.setdefault(key, default)
+        if pop:
+            return self.transaction_data.pop(key, default)
+        else:
+            return self.transaction_data.get(key, default)
+
+    @obsolete('use entity_from_eid(eid, etype=None)')
+    def entity(self, eid):
+        """return a result set for the given eid"""
+        return self.eid_rset(eid).get_entity(0, 0)
+
 
 class ChildSession(Session):
     """child (or internal) session are used to hijack the security system