552 def __hash__(self): |
552 def __hash__(self): |
553 if isinstance(self.eid, (int, long)): |
553 if isinstance(self.eid, (int, long)): |
554 return self.eid |
554 return self.eid |
555 return super(Entity, self).__hash__() |
555 return super(Entity, self).__hash__() |
556 |
556 |
557 def _cw_update_attr_cache(self, attrcache): |
|
558 trdata = self._cw.transaction_data |
|
559 uncached_attrs = trdata.get('%s.storage-special-process-attrs' % self.eid, set()) |
|
560 for attr in uncached_attrs: |
|
561 attrcache.pop(attr, None) |
|
562 self.cw_attr_cache.pop(attr, None) |
|
563 self.cw_attr_cache.update(attrcache) |
|
564 |
|
565 def _cw_dont_cache_attribute(self, attr, repo_side=False): |
|
566 """Called when some attribute has been transformed by a *storage*, |
|
567 hence the original value should not be cached **by anyone**. |
|
568 |
|
569 For example we have a special "fs_importing" mode in BFSS |
|
570 where a file path is given as attribute value and stored as is |
|
571 in the data base. Later access to the attribute will provide |
|
572 the content of the file at the specified path. We do not want |
|
573 the "filepath" value to be cached. |
|
574 |
|
575 """ |
|
576 trdata = self._cw.transaction_data |
|
577 trdata.setdefault('%s.storage-special-process-attrs' % self.eid, set()).add(attr) |
|
578 |
|
579 def __json_encode__(self): |
557 def __json_encode__(self): |
580 """custom json dumps hook to dump the entity's eid |
558 """custom json dumps hook to dump the entity's eid |
581 which is not part of dict structure itself |
559 which is not part of dict structure itself |
582 """ |
560 """ |
583 dumpable = self.cw_attr_cache.copy() |
561 dumpable = self.cw_attr_cache.copy() |