
noreply at edgewall
Jan 24, 2006, 11:17 PM
Views: 891
Permalink
|
|
[The Trac Project] #2661: (mod_python) TracError: The environment options "TRAC_ENV" ... are missing.
|
|
#2661: (mod_python) TracError: The environment options "TRAC_ENV" ... are missing. ---------------------------------+------------------------------------------ Reporter: schuetze[at]gmx.de | Owner: cmlenz Type: defect | Status: new Priority: normal | Milestone: Component: mod_python frontend | Version: 0.9.3 Severity: normal | Keywords: ---------------------------------+------------------------------------------ TRAC-0.9.3 / SVN-1.3.0 / Python-2.3.2 / Apache-2.0.55 / Windows-NT I tried to configure a TRAC environment for multiple projects. But my directory structure isn't compatible to the configuration described in TracModPython. I want to implement the multi project access with !RewriteRules of Apache - with these rules it's easy to "construct" the TRAC-path for the current project. The problem: In the parameters of a !RewriteRule, I can only define environment variables, but not !PythonOptions. For the mod_python-access to TRAC, only !PythonOptions are relevant: if I try to define the TRAC_ENV like {{{ SetEnv TRAC_ENV "d:/svn/test/trac.db" }}} this is not accepted by TRAC: {{{ PythonHandler trac.web.modpython_frontend: TracError: The environment options "TRAC_ENV" or "TRAC_ENV_PARENT_DIR" or the mod_python options "TracEnv" or "TracEnvParentDir" are missing. Trac requires one of these options to locate the Trac environment(s). }}} If I read this error text, I could understand that the definition of TRAC_ENV (= normal environment variable) and !TracEnv (= !PythonOption) are the same - but it isn't. The TRAC_ENV-definition with !SetEnv isn't possible. I haven't found a way to use such an environment variable to declare a !PythonOption within the location-directive. The following http.conf doesn't work: {{{ RewriteRule ^/projects/([^/]+)(/?) /projects/$1 [L,E=TRAC_ENV:d:/svn/$1/trac.db,E=TRAC_URI_ROOT:/projects/$1] <LocationMatch "/projects/[^/]+"> SetHandler mod_python PythonHandler trac.web.modpython_frontend PythonOption TracEnv %{TRAC_ENV} PythonOption TracUriRoot %{TRAC_URI_ROOT} </LocationMatch> }}} The solution could be a little patch of modpython_frontend.py: {{{ def handler(req): options = req.get_options() ... if req.subprocess_env.has_key('TRAC_ENV'): options['TracEnv'] = req.subprocess_env['TRAC_ENV'] if req.subprocess_env.has_key('TRAC_URI_ROOT'): options['TracUriRoot'] = req.subprocess_env['TRAC_URI_ROOT'] ... dict_translate ... }}} With these lines of code, the two important options "TracEnv" and "TracUriRoot" can be first defined as normal environment variables with a !RewriteRule and then be used as !PythonOption. My http.conf now: {{{ RewriteRule ^/projects/([^/]+)(/?) /projects/$1 [L,E=TRAC_ENV:d:/svn/$1/trac.db,E=TRAC_URI_ROOT:/projects/$1] <LocationMatch "/projects/[^/]+"> SetHandler mod_python PythonHandler trac.web.modpython_frontend </LocationMatch> <LocationMatch "/projects/[^/]+/login"> AuthType Basic AuthName "TRAC" AuthUserFile d:\svn\.htaccess Require valid-user </LocationMatch> }}} Now, every directory structure is possible with mod_python. -- Ticket URL: <http://projects.edgewall.com/trac/ticket/2661> The Trac Project <http://trac.edgewall.com/>
|