circuits.web.utils – Utilities — circuits 2.1.0 documentation

# circuits 2.1.0 documentation

# `circuits.web.utils` – Utilities

Utilities

This module implements utility functions.

## Events

none

## Components

none

## Functions

`circuits.web.utils.` `compress`(body, compress_level)

  Compress ‘body’ at the given compress_level.

`circuits.web.utils.` `dictform`(form)

`circuits.web.utils.` `get_ranges`(headervalue, content_length)

  Return a list of (start, stop) indices from a Range header, or None.

  Each (start, stop) tuple will be composed of two ints, which are suitable for use in a slicing operation. That is, the header “Range: bytes=3-6”, if applied against a Python string, is requesting resource[3:7]. This function will return the list [(3, 7)].

  If this function returns an empty list, you should return HTTP 416.

`circuits.web.utils.` `parse_body`(request, response, params)

`circuits.web.utils.` `parse_qs`(query_string) → dict

  Build a params dictionary from a query_string. If keep_blank_values is True (the default), keep values that are blank.

`circuits.web.utils.` `url`(request, path='', qs='', script_name=None, base=None, relative=None)

  Create an absolute URL for the given path.

  If ‘path’ starts with a slash (‘/’), this will return
    - (base + script_name + path + qs).
  If it does not start with a slash, this returns
    - (base + script_name [+ request.path] + path + qs).

  If script_name is None, request will be used to find a script_name, if available.

  If base is None, request.base will be used (if available).

  Finally, note that this function can be used to obtain an absolute URL for the current request path (minus the querystring) by passing no args. If you call url(qs=request.qs), you should get the original browser URL (assuming no internal redirections).

  If relative is False the output will be an absolute URL (including the scheme, host, vhost, and script_name). If True, the output will instead be a URL that is relative to the current request path, perhaps including ‘..’ atoms. If relative is the string ‘server’, the output will instead be a URL that is relative to the server root; i.e., it will start with a slash.