pyramid.url

Utility functions for dealing with URLs in pyramid

resource_url(resource, request, *elements, **kw)[source]

This is a backwards compatibility function. Its result is the same as calling:

request.resource_url(resource, *elements, **kw)

See pyramid.request.Request.resource_url() for more information.

route_url(route_name, request, *elements, **kw)[source]

This is a backwards compatibility function. Its result is the same as calling:

request.route_url(route_name, *elements, **kw)

See pyramid.request.Request.route_url() for more information.

current_route_url(request, *elements, **kw)[source]

This is a backwards compatibility function. Its result is the same as calling:

request.current_route_url(*elements, **kw)

See pyramid.request.Request.current_route_url() for more information.

route_path(route_name, request, *elements, **kw)[source]

This is a backwards compatibility function. Its result is the same as calling:

request.route_path(route_name, *elements, **kw)

See pyramid.request.Request.route_path() for more information.

current_route_path(request, *elements, **kw)[source]

This is a backwards compatibility function. Its result is the same as calling:

request.current_route_path(*elements, **kw)

See pyramid.request.Request.current_route_path() for more information.

static_url(path, request, **kw)[source]

This is a backwards compatibility function. Its result is the same as calling:

request.static_url(path, **kw)

See pyramid.request.Request.static_url() for more information.

static_path(path, request, **kw)[source]

This is a backwards compatibility function. Its result is the same as calling:

request.static_path(path, **kw)

See pyramid.request.Request.static_path() for more information.

urlencode(query, doseq=True, quote_via=<function quote_plus>)[source]

An alternate implementation of Python's stdlib urllib.parse.urlencode() function which accepts string keys and values within the query dict/sequence; all string keys and values are first converted to UTF-8 before being used to compose the query string.

The value of query must be a sequence of two-tuples representing key/value pairs or an object (often a dictionary) with an .items() method that returns a sequence of two-tuples representing key/value pairs.

For minimal calling convention backwards compatibility, this version of urlencode accepts but ignores a second argument conventionally named doseq. The Python stdlib version behaves differently when doseq is False and when a sequence is presented as one of the values. This version always behaves in the doseq=True mode, no matter what the value of the second argument.

Both the key and value are encoded using the quote_via function which by default is using a similar algorithm to urllib.parse.quote_plus() which converts spaces into '+' characters and '/' into '%2F'.

Changed in version 1.5: In a key/value pair, if the value is None then it will be dropped from the resulting output.

Changed in version 1.9: Added the quote_via argument to allow alternate quoting algorithms to be used.