Primary interface for handling web requests.
The following interfaces allow components to interact at various stages of the web requests processing pipeline.
Decide which trac.core.Component handles which Request, and how.
See also trac.web.api.IRequestHandler extension point
Return whether the handler wants to process the given request.
Process the request.
Return a (template_name, data, content_type) tuple, where data is a dictionary of substitutions for the Genshi template.
“text/html” is assumed if content_type is None.
Note that if template processing should not occur, this method can simply send the response itself and not return anything.
Since 1.0: | Clearsilver templates are no longer supported. |
---|
Enable components to interfere with the processing done by the main handler, either before and/or after it enters in action.
See also trac.web.api.IRequestFilter extension point
Do any post-processing the request might need; typically adding values to the template data dictionary, or changing the Genshi template or mime type.
data may be updated in place.
Always returns a tuple of (template, data, content_type), even if unchanged.
Since 0.11: | there’s a data argument for supporting Genshi templates; this introduced a difference in arity which made it possible to distinguish between the IRequestFilter components still targeted at ClearSilver templates and the newer ones targeted at Genshi templates. |
---|---|
Since 1.0: | Clearsilver templates are no longer supported. |
Called after initial handler selection, and can be used to change the selected handler or redirect request.
Always returns the request handler, even if unchanged.
For how the main content itself can be generated, see trac.web.chrome.
Transform the generated content by filtering the Genshi event stream generated by the template, prior to its serialization.
See also trac.web.api.ITemplateStreamFilter extension point
Return a filtered Genshi event stream, or the original unfiltered stream if no match.
req is the current request object, method is the Genshi render method (xml, xhtml or text), filename is the filename of the template to be rendered, stream is the event stream and data is the data for the current template.
See the Genshi documentation for more information.
Extension point interface for components that can provide the name of the remote user.
Represents a HTTP request/response pair.
This class provides a convenience API over WSGI.
Create the request wrapper.
Parameters: |
|
---|
The name associated with the user after authentification or 'anonymous' if no authentification took place.
This corresponds to the remote_user when the request is targeted to an area requiring authentication, otherwise the authname is retrieved from the trac_auth cookie.
An Href instance for generating relative URLs pointing to resources within the current Trac environment.
An Href instance for generating absolute URLs pointing to resources within the current Trac environment.
Add a callable to be called prior to executing a redirect.
The callable is passed the arguments to the redirect() call.
The root path of the application
Check the request “If-None-Match” header against an entity tag.
The entity tag is generated from the specified last modified time (datetime), optionally appending an extra string to indicate variants of the requested resource.
That extra parameter can also be a list, in which case the MD5 sum of the list content will be used.
If the generated tag matches the “If-None-Match” header of the request, this method sends a “304 Not Modified” response to the client. Otherwise, it adds the entity tag as an “ETag” header to the response so that consecutive requests can be cached.
Must be called after all headers have been sent and before the actual content is written.
Return the value of the specified HTTP header, or None if there’s no such header in the request.
The HTTP method of the request
Path inside the application
Query part of the request
Read the specified number of bytes from the request body.
Send a redirect to the client, forwarding to the specified URL.
The url may be relative or absolute, relative URLs will be translated appropriately.
IP address of the remote user
Name of the remote user.
Will be None if the user has not logged in using HTTP authentication.
The scheme of the request URL
Send a local file to the browser.
This method includes the “Last-Modified”, “Content-Type” and “Content-Length” headers in the response, corresponding to the file attributes. It also checks the last modification time of the local file against the “If-Modified-Since” provided by the user agent, and sends a “304 Not Modified” response if it matches.
Send the response header with the specified name and value.
value must either be an unicode string or can be converted to one (e.g. numbers, ...)
Set the status code of the response.
Name of the server
Port number the server is bound to
Write the given data to the response body.
data must be a str string or an iterable instance which iterates str strings, encoded with the charset which has been specified in the 'Content-Type' header or UTF-8 otherwise.
Note that when the 'Content-Length' header is specified, its value either corresponds to the length of data, or, if there are multiple calls to write, to the cumulative length of the data arguments.
Marker exception that indicates whether request processing has completed and a response was sent.