# HG changeset patch # User Sylvain Thénault # Date 1254485842 -7200 # Node ID 8facb3324170ae42ed53baa82444d004d66ecbd8 # Parent 5a73db781dacaa1f114b62859ad4b6a09f0cbe77 [entity] put cached related entities as tuple to be sure no one is modifying diff -r 5a73db781dac -r 8facb3324170 entity.py --- a/entity.py Fri Oct 02 14:15:23 2009 +0200 +++ b/entity.py Fri Oct 02 14:17:22 2009 +0200 @@ -804,7 +804,7 @@ else raise `KeyError` """ res = self._related_cache['%s_%s' % (rtype, role)][entities] - if limit: + if limit is not None: if entities: res = res[:limit] else: @@ -814,7 +814,7 @@ def set_related_cache(self, rtype, role, rset, col=0): """set cached values for the given relation""" if rset: - related = list(rset.entities(col)) + related = tuple(rset.entities(col)) rschema = self.schema.rschema(rtype) if role == 'subject': rcard = rschema.rproperty(self.e_schema, related[0].e_schema, @@ -826,9 +826,10 @@ target = 'subject' if rcard in '?1': for rentity in related: - rentity._related_cache['%s_%s' % (rtype, target)] = (self.as_rset(), [self]) + rentity._related_cache['%s_%s' % (rtype, target)] = ( + self.as_rset(), (self,)) else: - related = [] + related = () self._related_cache['%s_%s' % (rtype, role)] = (rset, related) def clear_related_cache(self, rtype=None, role=None):