trac.web.main – Trac Web Entry Point

Entry point for dispatching web requests.

trac.web.dispatch_request

The WSGI compliant callable. It adapts the environ information passed from the WSGI gateway and retrieve the appropriate Environment from it, creates a Request instance and let the RequestDispatcher component forward it to the component implementing a matching IRequestHandler.

trac.web.main.dispatch_request(environ, start_response)

Main entry point for the Trac web interface.

Parameters:
  • environ – the WSGI environment dict
  • start_response – the WSGI callback for starting the response

Components

class trac.web.main.RequestDispatcher

Bases: trac.core.Component

Web request dispatcher.

This component dispatches incoming requests to registered handlers. Besides, it also takes care of user authentication and request pre- and post-processing.

authenticators

List of components that implement IAuthenticator

default_date_format

The date format. Valid options are ‘iso8601’ for selecting ISO 8601 format, or leave it empty which means the default date format will be inferred from the browser’s default language. (‘’since 1.0’‘)

default_handler

Name of the component that handles requests to the base URL.

Options include TimelineModule, RoadmapModule, BrowserModule, QueryModule, ReportModule, TicketModule and WikiModule.

The [/prefs/userinterface session preference] for default handler take precedence, when set.

default_language

The preferred language to use if no user preference has been set.

default_timezone

The default timezone to use

dispatch(req)

Find a registered handler that matches the request and let it process it.

In addition, this method initializes the data dictionary passed to the the template and adds the web site chrome.

filters

Ordered list of filters to apply to all requests.

handlers

List of components that implement IRequestHandler

set_default_callbacks(req)

Setup request callbacks for lazily-evaluated properties.

use_xsendfile

When true, send a X-Sendfile header and no content when sending files from the filesystem, so that the web server handles the content. This requires a web server that knows how to handle such a header, like Apache with mod_xsendfile or lighttpd. (‘’since 1.0’‘)

xsendfile_header

The header to use if use_xsendfile is enabled. If Nginx is used, set X-Accel-Redirect. (‘’since 1.0.6’‘)

Classes

class trac.web.main.RequestWithSession(environ, start_response)

Bases: trac.web.api.Request

A request that saves its associated session when sending the reply.

Create the request wrapper.

Parameters:
  • environ – The WSGI environment dict
  • start_response – The WSGI callback for starting the response
  • callbacks – A dictionary of functions that are used to lazily evaluate attribute lookups

Helper Functions

trac.web.main.get_environments(environ, warn=False)

Retrieve canonical environment name to path mapping.

The environments may not be all valid environments, but they are good candidates.

trac.web.main.get_tracignore_patterns(env_parent_dir)

Return the list of patterns from env_parent_dir/.tracignore or a default pattern of ".*" if the file doesn’t exist.

Miscellaneous

trac.web.main.default_tracker = 'https://trac.edgewall.org'

str(object=’‘) -> string

Return a nice string representation of the object. If the argument is a string, the return value is the same object.