views:

143

answers:

2

I am trying to configure two Trac instances in order to access them via browser each one with a different url:

http://trac.domain.com/trac1
http://trac.domain.com/trac2

First time I access them Apache response is fine, I get the first Trac with /trac1, then the second one in /trac2. But when I access /trac1 again, it keeps giving me the contents of the second Trac (/trac2). If I touch the .wsgi config file for the first one (say it trac1.wsgi), then request again /trac1 with browser, I get the expected contents again.

The opposite case works equal: access /trac2, then /trac1, then /trac2 keeps giving the contents of /trac1 until I touch trac2.wsgi...

So it seems Python, mod_wsgi and/or Apache are caching results or something. I am not sysadmin and can't get further on this issue.

The .wsgi files and http.conf for Apache:

trac1.wsgi:

import os

os.environ['TRAC_ENV'] = '/home/myuser/trac/trac1'
os.environ['PYTHON_EGG_CACHE'] = '/tmp/'

import trac.web.main
application = trac.web.main.dispatch_request

trac2.wsgi:

import os

os.environ['TRAC_ENV'] = '/home/myuser/trac/trac2'
os.environ['PYTHON_EGG_CACHE'] = '/tmp/'

import trac.web.main
application = trac.web.main.dispatch_request

http.conf:

<VirtualHost trac.domain.com:8080>

    WSGIScriptAlias /trac1 /home/myuser/public_html/trac1/apache/trac1.wsgi
    WSGIScriptAlias /trac2 /home/myuser/public_html/trac2/apache/trac2.wsgi

    <Directory /home/myuser/public_html/trac1/apache>
        WSGIApplicationGroup %{GLOBAL}
        Order deny,allow
        Allow from all
    </Directory>

    <Location "/trac1">
        AuthType Basic
        AuthName "Trac1 Trac Auth"
        AuthUserFile /home/myuser/public_html/trac1/apache/trac1.htpasswd
        Require valid-user
    </Location>


    <Directory /home/myuser/public_html/trac2/apache>
        WSGIApplicationGroup %{GLOBAL}
        Order deny,allow
        Allow from all
    </Directory>

    <Location "/trac2">
        AuthType Basic
        AuthName "Trac2 Trac Auth"
        AuthUserFile /home/myuser/public_html/trac2/apache/trac2.htpasswd
        Require valid-user
    </Location>

</VirtualHost>

If anybody suggests an alternative configuration or whatever, it will be welcome as well. thanks!

Hector

A: 

Move your egg cache to separate dirs

trac1.wsgi:

import os

os.environ['TRAC_ENV'] = '/home/myuser/trac/trac1' 
os.environ['PYTHON_EGG_CACHE'] = '/tmp/trac1'

import trac.web.main 
application = trac.web.main.dispatch_request

trac2.wsgi:

import os

os.environ['TRAC_ENV'] = '/home/myuser/trac/trac2'
os.environ['PYTHON_EGG_CACHE'] = '/tmp/trac2'

import trac.web.main
application = trac.web.main.dispatch_request
Lance Rushing
+1  A: 

I found the solution myself, it was on the Trac documentation ("important note" section), and I did not event take look, fool of me :P

http://trac.edgewall.org/wiki/TracModWSGI

nabucosound
It isn't as simple as what the "important note" section said and by itself the configuration they describe shouldn't cause a problem. So, I would actually disagree with their specific example. I would suggest you read 'http://code.google.com/p/modwsgi/wiki/IntegrationWithTrac' and 'http://code.google.com/p/modwsgi/wiki/ApplicationIssues#Application_Environment_Variables'. The latter describes the problem of using os.environ. For Trac though should only be an issue where mixing TRAC_ENV and TRAC_ENV_PARENT_DIR. Short answer to avoid problems is used mod_wsgi daemon mode as shown in first link.
Graham Dumpleton