# HG changeset patch # User Nicolas Chauvat # Date 1242948620 -7200 # Node ID e23536d29231b0d35e1466b8db8c48f37332720f # Parent c30034fe074fa1a9f2e891f4f8ce82278878a4c4 minor refactoring of absolute_url() diff -r c30034fe074f -r e23536d29231 entity.py --- 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']