entity.py
branchstable
changeset 1904 e23536d29231
parent 1842 c7a22540d6f7
child 1977 606923dff11b
--- a/entity.py	Fri May 22 01:29:35 2009 +0200
+++ b/entity.py	Fri May 22 01:30:20 2009 +0200
@@ -379,7 +379,7 @@
         # XXX search_state is web specific
         if getattr(self.req, 'search_state', ('normal',))[0] == 'normal':
             kwargs['base_url'] = self.metainformation()['source'].get('base-url')
-        if method is None or method == 'view':
+        if method in (None, 'view'):
             try:
                 kwargs['_restpath'] = self.rest_path(kwargs.get('base_url'))
             except TypeError:
@@ -404,11 +404,10 @@
                 # make sure url is not ambiguous
                 rql = 'Any COUNT(X) WHERE X is %s, X %s %%(value)s' % (
                     etype, mainattr)
-                if value is not None:
-                    nbresults = self.req.execute(rql, {'value' : value})[0][0]
-                    if nbresults != 1: # ambiguity?
-                        mainattr = 'eid'
-                        path += '/eid'
+                nbresults = self.req.execute(rql, {'value' : value})[0][0]
+                if nbresults != 1: # ambiguity?
+                    mainattr = 'eid'
+                    path += '/eid'
         if mainattr == 'eid':
             if use_ext_eid:
                 value = self.metainformation()['extid']