--- a/server/sources/storages.py Tue Jun 01 08:34:35 2010 +0200
+++ b/server/sources/storages.py Wed Jun 02 13:02:47 2010 +0200
@@ -33,10 +33,10 @@
"""abstract storage
* If `source_callback` is true (by default), the callback will be run during
- query result process of fetched attribute's valu and should have the
+ query result process of fetched attribute's value and should have the
following prototype::
- callback(self, source, value)
+ callback(self, source, session, value)
where `value` is the value actually stored in the backend. None values
will be skipped (eg callback won't be called).
@@ -99,7 +99,7 @@
self.default_directory = defaultdir
self.fsencoding = fsencoding
- def callback(self, source, value):
+ def callback(self, source, session, value):
"""sql generator callback when some attribute with a custom storage is
accessed
"""
@@ -125,17 +125,18 @@
def entity_updated(self, entity, attr):
"""an entity using this storage for attr has been updatded"""
+ oldpath = self.current_fs_path(entity, attr)
if entity._cw.transaction_data.get('fs_importing'):
- oldpath = self.current_fs_path(entity, attr)
fpath = entity[attr].getvalue()
- if oldpath != fpath:
- hook.set_operation(entity._cw, 'bfss_deleted', oldpath,
- DeleteFileOp)
binary = Binary(file(fpath).read())
else:
binary = entity.pop(attr)
- fpath = self.current_fs_path(entity, attr)
+ fpath = self.new_fs_path(entity, attr)
UpdateFileOp(entity._cw, filepath=fpath, filedata=binary.getvalue())
+ if oldpath != fpath:
+ entity[attr] = Binary(fpath)
+ hook.set_operation(entity._cw, 'bfss_deleted', oldpath,
+ DeleteFileOp)
return binary
def entity_deleted(self, entity, attr):