entity.py
branchstable
changeset 3552 8facb3324170
parent 3546 f0aecddf367e
child 3589 a5432f99f2d9
child 3626 017869a514c3
--- 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):