server/sources/storages.py
changeset 10996 dc572d116731
parent 10706 b261d90149d0
child 10997 da712d3f0601
equal deleted inserted replaced
10995:c449f4415d0c 10996:dc572d116731
   152 
   152 
   153     def entity_added(self, entity, attr):
   153     def entity_added(self, entity, attr):
   154         """an entity using this storage for attr has been added"""
   154         """an entity using this storage for attr has been added"""
   155         if entity._cw.transaction_data.get('fs_importing'):
   155         if entity._cw.transaction_data.get('fs_importing'):
   156             binary = Binary.from_file(entity.cw_edited[attr].getvalue())
   156             binary = Binary.from_file(entity.cw_edited[attr].getvalue())
       
   157             entity._cw_dont_cache_attribute(attr)
   157         else:
   158         else:
   158             binary = entity.cw_edited.pop(attr)
   159             binary = entity.cw_edited.pop(attr)
   159             fd, fpath = self.new_fs_path(entity, attr)
   160             fd, fpath = self.new_fs_path(entity, attr)
   160             # bytes storage used to store file's path
   161             # bytes storage used to store file's path
   161             binary_obj = Binary(fpath if PY2 else fpath.encode('utf-8'))
   162             binary_obj = Binary(fpath if PY2 else fpath.encode('utf-8'))
   171         if entity._cw.transaction_data.get('fs_importing'):
   172         if entity._cw.transaction_data.get('fs_importing'):
   172             # If we are importing from the filesystem, the file already exists.
   173             # If we are importing from the filesystem, the file already exists.
   173             # We do not need to create it but we need to fetch the content of
   174             # We do not need to create it but we need to fetch the content of
   174             # the file as the actual content of the attribute
   175             # the file as the actual content of the attribute
   175             fpath = entity.cw_edited[attr].getvalue()
   176             fpath = entity.cw_edited[attr].getvalue()
       
   177             entity._cw_dont_cache_attribute(attr)
   176             assert fpath is not None
   178             assert fpath is not None
   177             binary = Binary.from_file(fpath)
   179             binary = Binary.from_file(fpath)
   178         else:
   180         else:
   179             # We must store the content of the attributes
   181             # We must store the content of the attributes
   180             # into a file to stay consistent with the behaviour of entity_add.
   182             # into a file to stay consistent with the behaviour of entity_add.