Exemplo n.º 1
0
 def _partial(self, path, params, anchor):
     """Prepare a resource path."""
     
     base, current, controller = self._base
     url = URL()
     
     if not path:
         url.path = str(URL(current).path)
     else:
         url.path = base if path.startswith('/') else controller
         url.path.append(path[1:] if path.startswith('/') else path)
     
     url.query = params
     url.fragment = anchor
     
     return str(url)
Exemplo n.º 2
0
 def _full(self, path, params, anchor, protocol, host, port):
     """Prepare a complete URL."""
     
     base, current, controller = self._base
     url = URL(current)
     
     url.path = self._partial(path, None, None)
     
     if protocol:
         url.scheme = protocol
     
     if host:
         url.host = host
     
     if port:
         url.port = port
     
     url.params = params
     url.fragment = anchor
     
     return str(url)