code: def url_for(*args, **kw):
          
          # Allow passing 'self' as named parameter
          self, target, args = args[0], args[1], list(args[2:])
          query = kw.pop('_query', None)
          relative = kw.pop('_relative', False)
          url = build_url(self._context, target, args, kw)
          if query:
              if isinstance(query, dict):
                  query = sorted(query.items())
              query_part = urllib.urlencode(query)
              query_sep = '&' if '?' in url else '?'
              url = url + query_sep + query_part
          if relative:
              return url
          else:
              return urlparse.urljoin(self.application_uri, url)
docs: Build the URL for a target route.
  
          The target is the first positional argument, and can be any valid
          target for `Mapper.path`, which will be looked up on the current
          mapper object and used to build the URL for that route.
          Additionally, it can be one of:
  
          '.'
            : Builds the URL for the current route.
  
          '/'
            : Builds the URL for the root (top-most) mapper object.
  
          '/a', '/a:b', etc.
            : Builds the URL for a named route relative to the root mapper.
  
          '.a', '..a', '..a:b', etc.
            : Builds a URL for a named route relative to the current mapper.
              Each additional leading '.' after the first one starts one
              level higher in the hierarchy of nested mappers (i.e. '.a' is
              equivalent to 'a').
  
          Special keyword arguments:
  
          `_query`
            : Append a query string to the URL (dict or list of tuples)
  
          `_relative`
            : When True, build a relative URL (default: False)
  
          All other keyword arguments are treated as parameters for the URL
          template.