Commit 0a1b0d35 authored by Julien Cristau's avatar Julien Cristau
Browse files

Backout "[entity,storage] remove hackish code from the bfss path

The merge of the repo-side and web-side entity caches doesn't actually work,
because entities have a _cw attribute which is sometimes a connection and
sometimes a web request, and whose nature changes not-really-predictably
whenever ResultSet.get_entity() is called and brings it out of the cache.

This reverts commit 59a79300f213.
parent c449f4415d0c
......@@ -559,6 +559,28 @@ class Entity(AppObject):
return self.eid
return super(Entity, self).__hash__()
def _cw_update_attr_cache(self, attrcache):
trdata = self._cw.transaction_data
uncached_attrs = trdata.get('' % self.eid, set())
for attr in uncached_attrs:
attrcache.pop(attr, None)
self.cw_attr_cache.pop(attr, None)
def _cw_dont_cache_attribute(self, attr, repo_side=False):
"""Called when some attribute has been transformed by a *storage*,
hence the original value should not be cached **by anyone**.
For example we have a special "fs_importing" mode in BFSS
where a file path is given as attribute value and stored as is
in the data base. Later access to the attribute will provide
the content of the file at the specified path. We do not want
the "filepath" value to be cached.
trdata = self._cw.transaction_data
trdata.setdefault('' % self.eid, set()).add(attr)
def __json_encode__(self):
"""custom json dumps hook to dump the entity's eid
which is not part of dict structure itself
......@@ -154,6 +154,7 @@ class BytesFileSystemStorage(Storage):
"""an entity using this storage for attr has been added"""
if entity._cw.transaction_data.get('fs_importing'):
binary = Binary.from_file(entity.cw_edited[attr].getvalue())
binary = entity.cw_edited.pop(attr)
fd, fpath = self.new_fs_path(entity, attr)
......@@ -173,6 +174,7 @@ class BytesFileSystemStorage(Storage):
# We do not need to create it but we need to fetch the content of
# the file as the actual content of the attribute
fpath = entity.cw_edited[attr].getvalue()
assert fpath is not None
binary = Binary.from_file(fpath)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment