server/repository.py
branchstable
changeset 7708 45be3a9debe6
parent 7706 359bc86d2827
child 7716 c893150b2394
--- a/server/repository.py	Wed Jul 27 14:22:32 2011 +0200
+++ b/server/repository.py	Wed Jul 27 14:24:40 2011 +0200
@@ -1032,7 +1032,7 @@
         return extid
 
     def extid2eid(self, source, extid, etype, session=None, insert=True,
-                  complete=True, sourceparams=None):
+                  complete=True, commit=True, sourceparams=None):
         """Return eid from a local id. If the eid is a negative integer, that
         means the entity is known but has been copied back to the system source
         hence should be ignored.
@@ -1095,10 +1095,12 @@
             source.after_entity_insertion(session, extid, entity, sourceparams)
             if source.should_call_hooks:
                 self.hm.call_hooks('after_add_entity', session, entity=entity)
-            session.commit(free_cnxset)
+            if commit:
+                session.commit(free_cnxset)
             return eid
-        except:
-            session.rollback(free_cnxset)
+        except Exception:
+            if commit:
+                session.rollback(free_cnxset)
             raise
 
     def add_info(self, session, entity, source, extid=None, complete=True):