Skip to content

Commit

Permalink
new reset cache suppor for the reloading of old values
Browse files Browse the repository at this point in the history
  • Loading branch information
joamag committed Jan 6, 2015
1 parent eef8d2a commit d613c5b
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
12 changes: 12 additions & 0 deletions data/src/entity_manager/structures.py
Original file line number Diff line number Diff line change
Expand Up @@ -2811,6 +2811,18 @@ def reset(self):
for relation in all_relations:
setattr(self, relation, colony.Lazy)

def reset_cache(self):
"""
Resets the entitie's cache for the current instance so that any
access to the data source will be used in "real mode" avoiding any
usage of an in memory view of objects.
This call may be required to avoid outdated and erroneous values
coming from data source access operations.
"""

self._entities = {}

def use_scope(self, scope_entity):
""""
Sets (uses) the scope and entities map attributes in the current
Expand Down
7 changes: 7 additions & 0 deletions data/src/entity_manager/system.py
Original file line number Diff line number Diff line change
Expand Up @@ -1977,6 +1977,13 @@ def reload(self, entity, options = None):
value = new_entity.get_value(name)
entity.set_value(name, value)

# resets the complete set of entity's cache mechanisms
# so that a new entity cache is created from this reload,
# this is required so that a new access context is created
# for the entity and related values coming from it avoiding
# old data to be retrieved/used instead
entity.reset_cache()

# enables the entity, providing the entity with the
# mechanisms necessary for data source communication
self.enable(entity)
Expand Down

0 comments on commit d613c5b

Please sign in to comment.