[dataimport] fix #1732685: cached entity and shared cw_edited data with NoHookRQLObjectStore
--- a/dataimport.py Tue Jun 07 12:54:45 2011 +0200
+++ b/dataimport.py Tue Jun 07 16:07:06 2011 +0200
@@ -642,7 +642,9 @@
for k, v in kwargs.iteritems():
kwargs[k] = getattr(v, 'eid', v)
entity, rels = self.metagen.base_etype_dicts(etype)
+ # make a copy to keep cached entity pristine
entity = copy(entity)
+ entity.cw_edited = copy(entity.cw_edited)
entity.cw_clear_relation_cache()
self.metagen.init_entity(entity)
entity.cw_edited.update(kwargs, skipsec=False)
--- a/server/edition.py Tue Jun 07 12:54:45 2011 +0200
+++ b/server/edition.py Tue Jun 07 16:07:06 2011 +0200
@@ -68,6 +68,11 @@
super(EditedEntity, self).__delitem__(attr)
self.entity.cw_attr_cache.pop(attr, None)
+ def __copy__(self):
+ # default copy protocol fails in EditedEntity.__setitem__ because
+ # copied entity has no skip_security attribute at this point
+ return EditedEntity(self.entity, **self)
+
def pop(self, attr, *args):
# don't update skip_security by design (think to storage api)
assert not self.saved, 'too late to modify edited attributes'