Changes between Initial Version and Version 1 of TracModPython

Oct 11, 2005, 12:24:32 AM (18 years ago)



  • TracModPython

    v1 v1  
     1= Trac and mod_python =
     3Trac supports [ 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.
     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 [ #1090])
     7== Simple configuration ==
     9If you just installed mod_python, you may have to add a line to load the module in the Apache configuration:
     11LoadModule python_module modules/
     14A simple setup of Trac on mod_python looks like this:
     16<Location /projects/myproject>
     17   SetHandler mod_python
     18   PythonHandler trac.ModPythonHandler
     19   PythonOption TracEnv /var/trac/myproject
     20   PythonOption TracUriRoot /projects/myproject
     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.
     26Configuring authentication works the same as for [wiki:TracCgi#AddingAuthentication CGI]:
     28<Location "/projects/myproject/login">
     29  AuthType Basic
     30  AuthName "myproject"
     31  AuthUserFile /var/trac/myproject/.htaccess
     32  Require valid-user
     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:
     38<Location /projects/myproject>
     39  ...
     40  PythonPath "sys.path + ['/path/to/trac']"
     41  ...
     45== Setting up multiple projects ==
     47The Trac mod_python handler handler supports a configuration option similar to Subversion's `SvnParentPath`, called `TracEnvParentDir`:
     49<Location /projects>
     50  SetHandler mod_python
     51  PythonHandler trac.ModPythonHandler
     52  PythonOption TracEnvParentDir /var/trac
     53  PythonOption TracUriRoot /projects
     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.
     59If you don't want to have the subdirectory listing as your projects home page you can use a
     61<LocationMatch "/.+/">
     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.
     66You can also use the same authentication realm for all of the projects using a `<LocationMatch>` directive:
     68<LocationMatch "/[^/]+/login">
     69  AuthType Basic
     70  AuthName "Trac"
     71  AuthUserFile /var/trac/.htaccess
     72  Require valid-user
     76== Troubleshooting ==
     78=== Form submission problems ===
     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.
     82=== Using .htaccess ===
     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.
     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. :)
     88=== Win32 Issues ===
     90If you run trac with mod_python on Windows, attachments will not work.
     92There is a (simple) workaround for this which is to apply the patch attached to
     93ticket [ #554].
     95=== OS X issues ===
     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 [ here].
     100See also TracGuide, TracInstall, TracCgi, TracFastCgi