Changes between Initial Version and Version 1 of TracModPython


Ignore:
Timestamp:
Oct 11, 2005, 12:16:57 AM (19 years ago)
Author:
trac
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • TracModPython

    v1 v1  
     1= Trac and mod_python =
     2
     3Trac 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 [wiki:TracStandalone tracd]/mod_proxy.
     4
     5Be sure to grab mod_python 3.1.3 and later for ''SetHandler'' ''mod_python'' directive to work.  Also, older versions may generate an internal error (see [http://projects.edgewall.com/trac/ticket/1090 #1090])
     6
     7== Simple configuration ==
     8
     9If you just installed mod_python, you may have to add a line to load the module in the Apache configuration:
     10{{{
     11LoadModule python_module modules/mod_python.so
     12}}}
     13
     14A simple setup of Trac on mod_python looks like this:
     15{{{
     16<Location /projects/myproject>
     17   SetHandler mod_python
     18   PythonHandler trac.ModPythonHandler
     19   PythonOption TracEnv /var/trac/myproject
     20   PythonOption TracUriRoot /projects/myproject
     21</Location>
     22}}}
     23
     24Note 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 or if Trac does not seem to recognize the URLs correctly, add the `TracUriRoot` option.
     25
     26Configuring authentication works the same as for [wiki:TracCgi#AddingAuthentication CGI]:
     27{{{
     28<Location "/projects/myproject/login">
     29  AuthType Basic
     30  AuthName "myproject"
     31  AuthUserFile /var/trac/myproject/.htaccess
     32  Require valid-user
     33</Location>
     34}}}
     35
     36If the Trac installation isn't installed in your Python path, you'll have to tell Apache where to find the Trac mod_python handler  using the `PythonPath` directive:
     37{{{
     38<Location /projects/myproject>
     39  ...
     40  PythonPath "sys.path + ['/path/to/trac']"
     41  ...
     42</Location>
     43}}}
     44
     45== Setting up multiple projects ==
     46
     47The Trac mod_python handler handler supports a configuration option similar to Subversion's `SvnParentPath`, called `TracEnvParentDir`:
     48{{{
     49<Location /projects>
     50  SetHandler mod_python
     51  PythonHandler trac.ModPythonHandler
     52  PythonOption TracEnvParentDir /var/trac
     53  PythonOption TracUriRoot /projects
     54</Location>
     55}}}
     56
     57When you request the `/projects` URL, you will get a listing of all subdirectories of the directory you set as `TracEnvParentDir`. Selecting any project in the list will bring you to the corresponding Trac environment.
     58
     59If you don't want to have the subdirectory listing as your projects home page you can use a
     60{{{
     61<LocationMatch "/.+/">
     62}}}
     63
     64This will instruct Apache to use mod_python for all locations different from root while having the possibility of placing a custom home page for root in your !DocumentRoot folder.
     65
     66You can also use the same authentication realm for all of the projects using a `<LocationMatch>` directive:
     67{{{
     68<LocationMatch "/[^/]+/login">
     69  AuthType Basic
     70  AuthName "Trac"
     71  AuthUserFile /var/trac/.htaccess
     72  Require valid-user
     73</LocationMatch>
     74}}}
     75
     76== Troubleshooting ==
     77
     78=== Form submission problems ===
     79
     80If you're experiencing problems submitting some of the forms in Trac (a common problem is that you get redirected to the start page after submission), check whether your {{{DocumentRoot}}} contains a folder or file with the same path that you mapped the mod_python handler to. For some reason, mod_python gets confused when it is mapped to a location that also matches a static resource.
     81
     82=== Using .htaccess ===
     83
     84Although it may seem trivial to rewrite the above configuration as a directory in your document root with a `.htaccess` file, this does not work. Apache will append a "/" to any Trac URLs, which interferes with its correct operation.
     85
     86It may be possible to work around this with mod_rewrite, but I failed to get this working. In all, it is more hassle than it is worth. Stick to the provided instructions. :)
     87
     88=== Win32 Issues ===
     89
     90If you run trac with mod_python on Windows, attachments will not work.
     91
     92There is a (simple) workaround for this which is to apply the patch attached to
     93ticket [http://projects.edgewall.com/trac/ticket/554 #554].
     94
     95=== OS X issues ===
     96
     97When using mod_python on OS X you will not be able to restart Apache using `apachectl restart`. This is apparently fixed in mod_python 3.2, but there's also a patch available for earlier versions [http://www.dscpl.com.au/projects/vampire/patches.html here].
     98
     99----
     100See also TracGuide, TracInstall, TracCgi, TracFastCgi