server/repository.py
changeset 8456 c912d82f2166
parent 8433 ff9d6d269877
child 8537 e30d0a7f0087
child 8547 f23ac525ddd1
--- a/server/repository.py	Mon Jul 09 09:47:28 2012 +0200
+++ b/server/repository.py	Fri Jul 06 14:01:09 2012 +0200
@@ -65,7 +65,7 @@
                            ('cw_source', 'object'),
                            ])
 
-def prefill_entity_caches(entity, relations):
+def prefill_entity_caches(entity):
     session = entity._cw
     # prefill entity relation caches
     for rschema in entity.e_schema.subject_relations():
@@ -1361,11 +1361,11 @@
         extid = self.init_entity_caches(session, entity, source)
         if server.DEBUG & server.DBG_REPO:
             print 'ADD entity', self, entity.__regid__, entity.eid, edited
-        relations = []
-        prefill_entity_caches(entity, relations)
+        prefill_entity_caches(entity)
         if source.should_call_hooks:
             self.hm.call_hooks('before_add_entity', session, entity=entity)
-        activintegrity = session.is_hook_category_activated('activeintegrity')
+        relations = []
+        activeintegrity = session.is_hook_category_activated('activeintegrity')
         for attr in edited.iterkeys():
             rschema = eschema.subjrels[attr]
             if not rschema.final: # inlined relation
@@ -1373,7 +1373,7 @@
                 relations.append((attr, value))
                 session.update_rel_cache_add(entity.eid, attr, value)
                 rdef = session.rtype_eids_rdef(attr, entity.eid, value)
-                if rdef.cardinality[1] in '1?' and activintegrity:
+                if rdef.cardinality[1] in '1?' and activeintegrity:
                     with security_enabled(session, read=False):
                         session.execute('DELETE X %s Y WHERE Y eid %%(y)s' % attr,
                                         {'x': entity.eid, 'y': value})