Edgewall Software
Home
Trac
Trac Hacks
Genshi
Babel
Bitten
Home
Download
Documentation
Mailing Lists
License
FAQ
Search:
Login
Preferences
Help/Guide
About Trac
Wiki
Timeline
Roadmap
Browse Source
View Tickets
New Ticket
Search
Context Navigation
+0
Start Page
Index
History
Editing ModPython
Adjust edit area height:
8
12
16
20
24
28
32
36
40
Edit side-by-side
= Trac and mod_python = Trac 0.7.1 and later supports [http://www.modpython.org/ mod_python], which speeds up Trac's response times considerably and permits use of many Apache features not possible with tracd/mod_proxy. '''Note''': The mod_python support in 0.7.1 has a couple of bugs that have since been fixed in both the [source:/branches/0.7-stable 0.7 branch] and [source:/trunk trunk], and will be released with [milestone:0.8 0.8]. == Simple configuration == Here's a typical Trac CGI/Apache setup: {{{ ScriptAlias /trac/myproject /path/to/python/share/trac/cgi-bin/trac.cgi <Location /trac/myproject> SetEnv TRAC_ENV /var/svn/trac/myproject </Location> }}} The equivalent mod_python setup is: {{{ <Location /trac/myproject> SetHandler mod_python PythonHandler trac.ModPythonHandler PythonOption TracUriRoot "/trac/myproject" PythonOption TracEnv /var/svn/trac/myproject </Location> }}} Note that the option ''TracUriRoot'' may or may not be necessary in your setup. Try without first, and if the URLs produced by Trac look wrong, add the ''TracUriRoot'' option. == Setting up multiple projects == === The easy way === The Trac mod_python handler handler supports a configuration option similar to Subversion's {{{SvnParentPath}}}, called {{{TracEnvParentDir}}}: {{{ <LocationMatch /trac> SetHandler mod_python PythonHandler trac.ModPythonHandler PythonOption TracUriRoot /trac PythonOption TracEnvParentDir "/var/www/projects" </LocationMatch> }}} When you request the {{{/trac}}} URL, you will get a (currently very simple) listing of all subdirectories of the directory you set as {{{TracEnvParentDir}}}. Selecting any project in the list will bring you to the corresponding Trac instance. You should make sure that the configured directory only contains Trac environment directories that match the currently installed Trac version, because that is not checked prior the the generation of the project list. === Or the hard way === The Trac mod_python handler can be configured to serve multiple projects, as can be seen in the following simple example: {{{ <LocationMatch /trac/[[:alnum:]]+> SetHandler mod_python PythonHandler trac.ModPythonHandler </LocationMatch> <Location /trac/exampleone> PythonOption TracUriRoot "/trac/exampleone" PythonOption TracEnv "/var/www/projects/exampleone" </Location> <Location /trac/exampletwo> PythonOption TracUriRoot "/trac/exampletwo" PythonOption TracEnv "/var/www/projects/exampletwo" </Location> }}} This sets up two projects. The disadvantage of the approach used here is that you need one additional {{{<Location>}}} directive per Trac instance. You may be able to eliminate this using some mod_rewrite tricks. === Adding authentication === Adding authentication is straightforward in both cases. For example: {{{ <LocationMatch /trac/[[:alnum:]]+/login> AuthType Basic AuthName "Trac" AuthUserFile /var/www/passwd Require valid-user </LocationMatch> }}} === Win32 Issues === If you run trac with mod_python on Windows, attachments will not work. There is a (simple) workaround for this which is to apply the patch attached to ticket #554. ---- See also TracGuide, TracInstall, TracMultipleProjects
Note:
See
WikiFormatting
and
TracWiki
for help on editing wiki content.
Change information
Your email or username:
E-mail address and name can be saved in the
Preferences
Comment about this change (optional):
Note:
See
TracWiki
for help on using the wiki.