[repository] replace session with cnx in a few places
authorJulien Cristau <julien.cristau@logilab.fr>
Fri, 04 Apr 2014 14:49:18 +0200
changeset 10315 0f3489d622ba
parent 10314 8f3783dc6358
child 10316 4ce8b8437838
[repository] replace session with cnx in a few places
devtools/fake.py
server/repository.py
--- a/devtools/fake.py	Mon Dec 01 16:50:41 2014 +0100
+++ b/devtools/fake.py	Fri Apr 04 14:49:18 2014 +0200
@@ -173,7 +173,7 @@
     def internal_session(self):
         return FakeSession(self)
 
-    def extid2eid(self, source, extid, etype, session, insert=True):
+    def extid2eid(self, source, extid, etype, cnx, insert=True):
         try:
             return self.extids[extid]
         except KeyError:
@@ -181,10 +181,10 @@
                 return None
             self._count += 1
             eid = self._count
-            entity = source.before_entity_insertion(session, extid, etype, eid)
+            entity = source.before_entity_insertion(cnx, extid, etype, eid)
             self.extids[extid] = eid
             self.eids[eid] = extid
-            source.after_entity_insertion(session, extid, entity)
+            source.after_entity_insertion(cnx, extid, entity)
             return eid
 
 
--- a/server/repository.py	Mon Dec 01 16:50:41 2014 +0100
+++ b/server/repository.py	Fri Apr 04 14:49:18 2014 +0200
@@ -1041,22 +1041,22 @@
                         cnx.pending_operations = pending_operations
                 raise
 
-    def add_info(self, session, entity, source, extid=None):
+    def add_info(self, cnx, entity, source, extid=None):
         """add type and source info for an eid into the system table,
         and index the entity with the full text index
         """
         # begin by inserting eid/type/source/extid into the entities table
-        hook.CleanupNewEidsCacheOp.get_instance(session).add_data(entity.eid)
-        self.system_source.add_info(session, entity, source, extid)
+        hook.CleanupNewEidsCacheOp.get_instance(cnx).add_data(entity.eid)
+        self.system_source.add_info(cnx, entity, source, extid)
 
-    def _delete_cascade_multi(self, session, entities):
+    def _delete_cascade_multi(self, cnx, entities):
         """same as _delete_cascade but accepts a list of entities with
         the same etype and belonging to the same source.
         """
-        pendingrtypes = session.transaction_data.get('pendingrtypes', ())
+        pendingrtypes = cnx.transaction_data.get('pendingrtypes', ())
         # delete remaining relations: if user can delete the entity, he can
         # delete all its relations without security checking
-        with session.security_enabled(read=False, write=False):
+        with cnx.security_enabled(read=False, write=False):
             in_eids = ','.join([str(_e.eid) for _e in entities])
             for rschema, _, role in entities[0].e_schema.relation_definitions():
                 if rschema.rule:
@@ -1071,7 +1071,7 @@
                 else:
                     rql = 'DELETE Y %s X WHERE X eid IN (%s)' % (rtype, in_eids)
                 try:
-                    session.execute(rql, build_descr=False)
+                    cnx.execute(rql, build_descr=False)
                 except ValidationError:
                     raise
                 except Unauthorized: