Commit 8bc4c612 authored by Sylvain Thénault's avatar Sylvain Thénault
Browse files

cache result of the COUNT query used to see if a non unique attribute may be...

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
parent 817851a77e27
......@@ -316,9 +316,12 @@ class Entity(AppObject, dict):
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'
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment