OPSI.web2.server module

This is a web-sever which integrates with the twisted.internet infrastructure.

class OPSI.web2.server.Request(*args, **kw)

Bases: OPSI.web2.http.Request

vars: site

remoteAddr

scheme host port path params querystring

args files

prepath postpath

@ivar path: The path only (arguments not included). @ivar args: All of the arguments, including URL and POST arguments. @type args: A mapping of strings (the argument names) to lists of values.

i.e., ?foo=bar&foo=baz&quux=spam results in {‘foo’: [‘bar’, ‘baz’], ‘quux’: [‘spam’]}.
addResponseFilter(f, atEnd=False)
locateChildResource(parent, childName)

Looks up the child resource with the given name given the parent resource. This is similar to locateResource(), but doesn’t have to start the lookup from the root resource, so it is potentially faster. @param parent: the parent of the resource being looked up. This resource

must have been obtained from the request (ie. via its C{uri} attribute, or through its C{locateResource} or C{locateChildResource} methods).
@param childName: the name of the child of C{parent} to looked up.
to C{parent}.
@return: a L{Deferred} resulting in the L{IResource} at the
given URL or C{None} if no such resource can be located.
@raise NoURLForResourceError: if C{resource} was not obtained from the
request.
locateResource(url)

Looks up the resource with the given URL. @param uri: The URL of the desired resource. @return: a L{Deferred} resulting in the L{IResource} at the

given URL or C{None} if no such resource can be located.
@raise HTTPError: If C{url} is not a URL on the site that this
request is being applied to. The contained response will have a status code of L{responsecode.BAD_GATEWAY}.
@raise HTTPError: If C{url} contains a query or fragment.
The contained response will have a status code of L{responsecode.BAD_REQUEST}.
preprocessRequest()

Do any request processing that doesn’t follow the normal resource lookup procedure. “OPTIONS *” is handled here, for example. This would also be the place to do any CONNECT processing.

process()

Process a request.

renderHTTP_exception(req, reason)
responseFilters = [<function rangefilter>, <function preconditionfilter>, <function defaultErrorHandler>, <function defaultHeadersFilter>]
site = None
unparseURL(scheme=None, host=None, port=None, path=None, params=None, querystring=None, fragment=None)

Turn the request path into a url string. For any pieces of the url that are not specified, use the value from the request. The arguments have the same meaning as the same named attributes of Request.

urlForResource(resource)

Looks up the URL of the given resource if this resource was found while processing this request. Specifically, this includes the requested resource, and resources looked up via L{locateResource}.

Note that a resource may be found at multiple URIs; if the same resource is visited at more than one location while processing this request, this method will return one of those URLs, but which one is not defined, nor whether the same URL is returned in subsequent calls.

@param resource: the resource to find a URI for. This resource must
have been obtained from the request (ie. via its C{uri} attribute, or through its C{locateResource} or C{locateChildResource} methods).

@return: a valid URL for C{resource} in this request. @raise NoURLForResourceError: if C{resource} has no URL in this request

(because it was not obtained from the request).
class OPSI.web2.server.Site(resource)

Bases: object

class OPSI.web2.server.StopTraversal

Bases: object

Indicates to Request._handleSegment that it should stop handling path segments.

OPSI.web2.server.defaultHeadersFilter(request, response)
OPSI.web2.server.doTrace(request)
OPSI.web2.server.parsePOSTData(request)
OPSI.web2.server.preconditionfilter(request, response)
exception OPSI.web2.server.NoURLForResourceError(resource)

Bases: exceptions.RuntimeError