Class n.u.URL(object):

Part of nevow.url View Source View In Hierarchy

Represents a URL and provides a convenient API for modifying its parts.

A URL is split into a number of distinct parts: scheme, netloc (domain
name), path segments, query parameters and fragment identifier.

Methods are provided to modify many of the parts of the URL, especially
the path and query parameters. Values can be passed to methods as-is;
encoding and escaping is handled automatically.

There are a number of ways to create a URL:
    * Standard Python creation, i.e. __init__.
    * fromString, a class method that parses a string.
    * fromContext, a class method that creates a URL to represent the
      the current URL in the path traversal process.
      
URL instances can be used in a stan tree or to fill template slots. They can
also be used as a redirect mechanism - simply return an instance from an
IResource method. See URLRedirectAdapter for details.
Line # Kind Name Docs
51 Method __init__ Undocumented
64 Method __eq__ Undocumented
72 Method __ne__ Undocumented
87 Class Method fromString Undocumented
96 Class Method fromRequest Undocumented
108 Class Method fromContext Create a URL object that represents the current URL in the traversal
120 Method pathList Undocumented
128 Method sibling Construct a url where the given path segment is a sibling of this url
135 Method child Construct a url where the given path segment is a child of this url
145 Method isRoot Undocumented
148 Method parent Undocumented
156 Method curdir Construct a url which is a logical equivalent to '.'
170 Method up Pop a URL segment from this url.
178 Method parentdir Construct a url which is the parent of this url's directory;
199 Method click Build a path by merging 'href' and this path.
240 Method queryList Return current query as a list of tuples.
248 Method add Add a query argument with the given value
256 Method replace Remove all existing occurrances of the query
273 Method remove Remove all query arguments with the given name
281 Method clear Remove all existing query arguments
292 Method secure Modify the scheme to https/http and return the new URL.
314 Method anchor Modify the fragment/anchor and return a new URL. An anchor of
322 Method __str__ Undocumented
325 Method __repr__ Undocumented
def __init__(self, scheme='http', netloc='localhost', pathsegs=None, querysegs=None, fragment=''): (source)
Undocumented
def __eq__(self, other): (source)
Undocumented
def __ne__(self, other): (source)
Undocumented
@classmethod
def fromString(klass, st): (source)
Undocumented
@classmethod
def fromRequest(klass, request): (source)
Undocumented
@classmethod
def fromContext(klass, context): (source)
Create a URL object that represents the current URL in the traversal process.
def pathList(self, unquote=False, copy=True): (source)
Undocumented
def sibling(self, path): (source)
Construct a url where the given path segment is a sibling of this url
def child(self, path): (source)
Construct a url where the given path segment is a child of this url
def isRoot(self, pathlist): (source)
Undocumented
def parent(self): (source)
Undocumented
def curdir(self): (source)
Construct a url which is a logical equivalent to '.' of the current url. For example:
>>> print URL.fromString('http://foo.com/bar').curdir()
http://foo.com/

>>> print URL.fromString('http://foo.com/bar/').curdir()
http://foo.com/bar/
def up(self): (source)
Pop a URL segment from this url.
def parentdir(self): (source)
Construct a url which is the parent of this url's directory; This is logically equivalent to '..' of the current url. For example:
>>> print URL.fromString('http://foo.com/bar/file').parentdir()
http://foo.com/

>>> print URL.fromString('http://foo.com/bar/dir/').parentdir()
http://foo.com/bar/
def click(self, href): (source)

Build a path by merging 'href' and this path.

Return a path which is the URL where a browser would presumably take you if you clicked on a link with an 'href' as given.
def queryList(self, copy=True): (source)
Return current query as a list of tuples.
def add(self, name, value=None): (source)
Add a query argument with the given value None indicates that the argument has no value
def replace(self, name, value=None): (source)
Remove all existing occurrances of the query argument 'name', *if it exists*, then add the argument with the given value. None indicates that the argument has no value
def remove(self, name): (source)
Remove all query arguments with the given name
def clear(self, name=None): (source)
Remove all existing query arguments
def secure(self, secure=True, port=None): (source)
Modify the scheme to https/http and return the new URL.
Parameterssecurechoose between https and http, default to True (https)
portport, override the scheme's normal port
def anchor(self, anchor=None): (source)
Modify the fragment/anchor and return a new URL. An anchor of None (the default) or '' (the empty string) will the current anchor.
def __str__(self): (source)
Undocumented
def __repr__(self): (source)
Undocumented
API Documentation for Nevow, generated by pydoctor.