equal
deleted
inserted
replaced
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 |