entity.py
changeset 4363 5c18d82042fb
parent 4252 6c4f109c2b03
child 4436 294e084f1263
--- 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'