Edgewall Software

Changes between Version 22 and Version 23 of TracModWSGI


Ignore:
Timestamp:
May 27, 2009, 7:17:58 PM (15 years ago)
Author:
sebastian@…
Comment:

Added note about severe problem when using multiple .wsgi files.

Legend:

Unmodified
Added
Removed
Modified
  • TracModWSGI

    v22 v23  
    1010
    1111{{{
     12#!python
    1213import os
    1314
     
    1920}}}
    2021
    21 The {{{TRAC_ENV}}} variable should naturally be the directory for your Trac environment (if you have several Trac environments in a directory, you can also use {{{TRAC_ENV_PARENT_DIR}}} instead), while the {{{PYTHON_EGG_CACHE}}} should be a directory where Python can temporarily extract Python eggs. [[BR]]
    22 For clarity, you should give this file a {{{.wsgi}}} extension. You should probably put the file in it's own directory, since you will open up its directory to Apache.
    23 You can create a .wsgi files which handles all this for you by running the TracAdmin command {{{deploy}}}.
     22The `TRAC_ENV` variable should naturally be the directory for your Trac environment (if you have several Trac environments in a directory, you can also use `TRAC_ENV_PARENT_DIR` instead), while the `PYTHON_EGG_CACHE` should be a directory where Python can temporarily extract Python eggs.
     23
     24'''Important note:''' If you're using multiple `.wsgi` files (for example one per Trac environment) you must ''not'' use `os.environ['PYTHON_EGG_CACHE']` to set the path to the Trac environment. Using this method may lead to Trac delivering the content of another Trac environment. (The variable may be filled with the path of a previously viewed Trac environment.) To solve this problem, use the following `.wsgi` file instead:
     25
     26{{{
     27#!python
     28import os
     29
     30os.environ['PYTHON_EGG_CACHE'] = '/usr/local/trac/mysite/eggs'
     31
     32import trac.web.main
     33def application(environ, start_response):
     34  environ['trac.env_path'] = '/usr/local/trac/mysite'
     35  return trac.web.main.dispatch_request(environ, start_response)
     36}}}
     37
     38For clarity, you should give this file a `.wsgi` extension. You should probably put the file in it's own directory, since you will open up its directory to Apache. You can create a .wsgi files which handles all this for you by running the TracAdmin command `deploy`.
    2439
    2540If you have installed trac and eggs in a path different from the standard one you should add that path by adding the following code on top of the wsgi script:
     41
    2642{{{
     43#!python
    2744import site
    2845site.addsitedir('/usr/local/trac/lib/python2.4/site-packages')
    2946}}}
     47
    3048Change it according to the path you installed the trac libs at.
    3149