entity.py
branchstable
changeset 3679 983c1af59c2a
parent 3672 554a588ffaea
child 3680 af3656d03376
equal deleted inserted replaced
3673:9342e6783bd2 3679:983c1af59c2a
   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:
   813         if limit is not None and limit < len(rset):
   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