# HG changeset patch # User Sylvain Thénault # Date 1264508860 -3600 # Node ID 5c18d82042fb737107343eb22827b5952ce35caf # Parent 817851a77e27d0ee01da5f50e577c06ba873a60a cache result of the COUNT query used to see if a non unique attribute may be used as rest path on the entity instance to avoid recomputing it later diff -r 817851a77e27 -r 5c18d82042fb entity.py --- a/entity.py Tue Jan 26 13:26:41 2010 +0100 +++ b/entity.py Tue Jan 26 13:27:40 2010 +0100 @@ -316,9 +316,12 @@ path += '/eid' elif needcheck: # make sure url is not ambiguous - rql = 'Any COUNT(X) WHERE X is %s, X %s %%(value)s' % ( - etype, mainattr) - nbresults = self._cw.execute(rql, {'value' : value})[0][0] + try: + nbresults = self.__unique + except AttributeError: + rql = 'Any COUNT(X) WHERE X is %s, X %s %%(value)s' % ( + etype, mainattr) + nbresults = self.__unique = self._cw.execute(rql, {'value' : value})[0][0] if nbresults != 1: # ambiguity? mainattr = 'eid' path += '/eid'