entity.py
branchstable
changeset 3680 af3656d03376
parent 3679 983c1af59c2a
child 3683 2e4794c97cf4
equal deleted inserted replaced
3679:983c1af59c2a 3680:af3656d03376
   808     def related_cache(self, rtype, role, entities=True, limit=None):
   808     def related_cache(self, rtype, role, entities=True, limit=None):
   809         """return values for the given relation if it's cached on the instance,
   809         """return values for the given relation if it's cached on the instance,
   810         else raise `KeyError`
   810         else raise `KeyError`
   811         """
   811         """
   812         res = self._related_cache['%s_%s' % (rtype, role)][entities]
   812         res = self._related_cache['%s_%s' % (rtype, role)][entities]
   813         if limit is not None and limit < len(rset):
   813         if limit is not None and limit < len(res):
   814             if entities:
   814             if entities:
   815                 res = res[:limit]
   815                 res = res[:limit]
   816             else:
   816             else:
   817                 res = res.limit(limit)
   817                 res = res.limit(limit)
   818         return res
   818         return res