Commit 4c847bbd authored by Sylvain Thénault's avatar Sylvain Thénault
Browse files

absolute_url / build_url refactoring to avoid potential name clash

parent 7ef12c03447c
......@@ -109,11 +109,16 @@ class RequestSessionMixIn(object):
# url generation methods ##################################################
def build_url(self, method, base_url=None, **kwargs):
def build_url(self, *args, **kwargs):
"""return an absolute URL using params dictionary key/values as URL
parameters. Values are automatically URL quoted, and the
publishing method to use may be specified or will be guessed.
"""
# use *args since we don't want first argument to be "anonymous" to
# avoid potential clash with kwargs
assert len(args) == 1, 'only 0 or 1 non-named-argument expected'
method = args[0]
base_url = kwargs.pop('base_url', None)
if base_url is None:
base_url = self.base_url()
if '_restpath' in kwargs:
......
......@@ -204,11 +204,18 @@ class AppRsetObject(VObject):
controller = 'view'
def build_url(self, method=None, **kwargs):
def build_url(self, *args, **kwargs):
"""return an absolute URL using params dictionary key/values as URL
parameters. Values are automatically URL quoted, and the
publishing method to use may be specified or will be guessed.
"""
# use *args since we don't want first argument to be "anonymous" to
# avoid potential clash with kwargs
if args:
assert len(args) == 1, 'only 0 or 1 non-named-argument expected'
method = args[0]
else:
method = None
# XXX I (adim) think that if method is passed explicitly, we should
# not try to process it and directly call req.build_url()
if method is None:
......
......@@ -373,8 +373,15 @@ class Entity(AppRsetObject, dict):
return self.vreg.render(vid, self.req, rset=self.rset,
row=self.row, col=self.col, **kwargs)
def absolute_url(self, method=None, **kwargs):
def absolute_url(self, *args, **kwargs):
"""return an absolute url to view this entity"""
# use *args since we don't want first argument to be "anonymous" to
# avoid potential clash with kwargs
if args:
assert len(args) == 1, 'only 0 or 1 non-named-argument expected'
method = args[0]
else:
method = None
# in linksearch mode, we don't want external urls else selecting
# the object for use in the relation is tricky
# XXX search_state is web specific
......
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