Skip to content

Commit

Permalink
ensure _dict_cache is reset after save
Browse files Browse the repository at this point in the history
  • Loading branch information
sheppard committed Jan 28, 2015
1 parent 2a2dc7d commit 3e5ce5c
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions patterns/relate/models.py
Expand Up @@ -149,10 +149,17 @@ def right_dict(self):
}
return cache[key]

def _reset_dict_cache(self):
for cls in Relationship, InverseRelationship:
key = cls._cache_prefix + str(self.pk)
if key in cls._dict_cache:
del cls._dict_cache[key]

def save(self, *args, **kwargs):
rightct = self.reltype.right
self.right = rightct.get_object_for_this_type(pk=self.right_object_id)
super(Relationship, self).save(*args, **kwargs)
self._reset_dict_cache()

def __str__(self):
if (self.from_content_type_id and self.type_id
Expand Down

0 comments on commit 3e5ce5c

Please sign in to comment.