Changes between Initial Version and Version 1 of ModPython


Ignore:
Timestamp:
11/17/04 15:27:55 (19 years ago)
Author:
trac
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • ModPython

    v1 v1  
     1= Trac and mod_python =
     2
     3Trac 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.
     4
     5'''Note''': The mod_python support in 0.7.1 has a couple of bugs that have since been fixed in both the [http://projects.edgewall.com/trac/browser/branches/0.7-stable 0.7 branch] and [http://projects.edgewall.com/trac/browser/trunk trunk], and will be released with [http://projects.edgewall.com/trac/milestone/0.8 0.8].
     6
     7== Simple configuration ==
     8
     9Here's a typical Trac CGI/Apache setup:
     10
     11{{{
     12ScriptAlias /trac/myproject /path/to/python/share/trac/cgi-bin/trac.cgi
     13<Location /trac/myproject>
     14   SetEnv TRAC_ENV /var/svn/trac/myproject
     15</Location>
     16}}}
     17
     18The equivalent mod_python setup is:
     19
     20{{{
     21<Location /trac/myproject>
     22   SetHandler mod_python
     23   PythonHandler trac.ModPythonHandler
     24   PythonOption TracUriRoot "/trac/myproject"
     25   PythonOption TracEnv /var/svn/trac/myproject
     26</Location>
     27}}}
     28
     29Note 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.
     30
     31== Setting up multiple projects ==
     32
     33=== The easy way ===
     34
     35The Trac mod_python handler handler supports a configuration option similar to Subversion's {{{SvnParentPath}}}, called {{{TracEnvParentDir}}}:
     36
     37{{{
     38<LocationMatch /trac>
     39  SetHandler mod_python
     40  PythonHandler trac.ModPythonHandler
     41  PythonOption TracUriRoot /trac
     42  PythonOption TracEnvParentDir "/var/www/projects"
     43</LocationMatch>
     44}}}
     45
     46When 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.
     47
     48=== Or the hard way ===
     49
     50The Trac mod_python handler can be configured to serve multiple projects, as can be seen in the following simple example:
     51
     52{{{
     53<LocationMatch /trac/[[:alnum:]]+>
     54  SetHandler mod_python
     55  PythonHandler trac.ModPythonHandler
     56</LocationMatch>
     57<Location /trac/exampleone>
     58  PythonOption TracUriRoot "/trac/exampleone"
     59  PythonOption TracEnv "/var/www/projects/exampleone"
     60</Location>
     61<Location /trac/exampletwo>
     62  PythonOption TracUriRoot "/trac/exampletwo"
     63  PythonOption TracEnv "/var/www/projects/exampletwo"
     64</Location>
     65}}}
     66
     67This 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.
     68
     69=== Adding authentication ===
     70
     71Adding authentication is straightforward in both cases. For example:
     72
     73{{{
     74<LocationMatch /trac/[[:alnum:]]+/login>
     75  AuthType Basic
     76  AuthName "Trac"
     77  AuthUserFile /var/www/passwd
     78  Require valid-user
     79</LocationMatch>
     80}}}
     81
     82=== Win32 Issues ===
     83
     84If you run trac with mod_python on Windows, attachments will not work.
     85
     86There is a (simple) workaround for this which is to apply the patch attached to
     87ticket [http://projects.edgewall.com/trac/ticket/554 #554].
     88
     89
     90----
     91See also TracGuide, TracInstall, TracMultipleProjects