Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Trac: Tickets

[The Trac Project] #2661: (mod_python) TracError: The environment options "TRAC_ENV" ... are missing.

 

 

Trac tickets RSS feed   Index | Next | Previous | View Threaded


noreply at edgewall

Jan 24, 2006, 11:17 PM

Post #1 of 7 (890 views)
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/>


noreply at edgewall

Jan 25, 2006, 4:51 AM

Post #2 of 7 (895 views)
Permalink
Re: [The Trac Project] #2661: (mod_python) TracError: The environment options "TRAC_ENV" ... are missing. [In reply to]

#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 | Resolution:
Keywords: |
---------------------------------+------------------------------------------
Comment (by cboos):

Can you try this patch:
{{{
Index: modpython_frontend.py
===================================================================
--- modpython_frontend.py (revision 2797)
+++ modpython_frontend.py (working copy)
@@ -172,8 +172,7 @@
self.list.append(util.Field(key, StringIO(value),
'text/plain',
{}, None, {}))

-def dict_translate(orig, *mappings):
- result = {}
+def dict_translate(result, orig, *mappings):
for src, dest in mappings:
if src in orig:
result[dest] = orig[src]
@@ -191,7 +190,7 @@
os.environ['PYTHON_EGG_CACHE'] =
req.subprocess_env['PYTHON_EGG_CACHE']

mpr = ModPythonRequest(req, options)
- project_opts = dict_translate(options,
+ project_opts = dict_translate(dict(os.environ), options,
('TracEnv', 'TRAC_ENV'),
('TracEnvParentDir', 'TRAC_ENV_PARENT_DIR'),
('TracEnvIndexTemplate', 'TRAC_ENV_INDEX_TEMPLATE'),
}}}
and retry with:
{{{
SetEnv TRAC_ENV "d:/svn/test/trac.db"
}}}
and without setting `PythonOption TracEnv`.

--
Ticket URL: <http://projects.edgewall.com/trac/ticket/2661>
The Trac Project <http://trac.edgewall.com/>


noreply at edgewall

Jan 26, 2006, 4:06 AM

Post #3 of 7 (834 views)
Permalink
Re: [The Trac Project] #2661: (mod_python) TracError: The environment options "TRAC_ENV" ... are missing. [In reply to]

#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 | Resolution:
Keywords: |
---------------------------------+------------------------------------------
Comment (by anonymous):

This patch is more general than my additional code. For me, this ticket
can be closed because the problem is solved and will be available for all
with the next release ...

--
Ticket URL: <http://projects.edgewall.com/trac/ticket/2661>
The Trac Project <http://trac.edgewall.com/>


noreply at edgewall

Jul 8, 2006, 7:44 PM

Post #4 of 7 (823 views)
Permalink
Re: [The Trac Project] #2661: (mod_python) TracError: The environment options "TRAC_ENV" ... are missing. [In reply to]

#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 | Resolution:
Keywords: |
---------------------------------+------------------------------------------
Comment (by mgood):

Replying to [comment:2 anonymous]:
> This patch is more general than my additional code. For me, this ticket
can be closed because the problem is solved and will be available for all
with the next release ...

Do you mean the patch posted by cboos fixed it, or was there another
change which has been committed which fixed the problem? I'm actually not
sure cboos's patch would help since I believe that the settings would need
pulled from `req.subprocess_env`, not `os.environ`.

If this is working for you I would like to close this ticket, but I'm not
sure I understand what solved it for you.

--
Ticket URL: <http://projects.edgewall.com/trac/ticket/2661>
The Trac Project <http://trac.edgewall.com/>
_______________________________________________
Trac-Tickets mailing list
Trac-Tickets[at]lists.edgewall.com
http://lists.edgewall.com/mailman/listinfo/trac-tickets


noreply at edgewall

Sep 8, 2006, 3:25 AM

Post #5 of 7 (802 views)
Permalink
Re: [The Trac Project] #2661: (mod_python) TracError: The environment options "TRAC_ENV" ... are missing. [In reply to]

#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 | Resolution:
Keywords: |
---------------------------------+------------------------------------------
Comment (by schuetze[at]gmx.de):

I haven't tested the patch of cboos. For the current version (0.10b1), my
patch and the patch of cboos can't be used anymore - the code has been
changed. Does the object {{{req.subprocess_env}}} exist? Is a new patch
available?

--
Ticket URL: <http://trac.edgewall.org/ticket/2661#comment:4>
The Trac Project <http://trac.edgewall.org/>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Trac Tickets" group.
To post to this group, send email to trac-tickets[at]googlegroups.com
To unsubscribe from this group, send email to trac-tickets-unsubscribe[at]googlegroups.com
For more options, visit this group at http://groups.google.se/group/trac-tickets
-~----------~----~----~----~------~----~------~--~---


noreply at edgewall

Sep 20, 2006, 3:37 PM

Post #6 of 7 (787 views)
Permalink
Re: [The Trac Project] #2661: (mod_python) TracError: The environment options "TRAC_ENV" ... are missing. [In reply to]

#2661: (mod_python) TracError: The environment options "TRAC_ENV" ... are missing.
---------------------------------+------------------------------------------
Reporter: schuetze[at]gmx.de | Owner: mgood
Type: defect | Status: new
Priority: normal | Milestone: 0.10.1
Component: mod_python frontend | Version: 0.9.3
Severity: normal | Resolution:
Keywords: |
---------------------------------+------------------------------------------
Changes (by mgood):

* owner: cmlenz => mgood
* milestone: => 0.10.1

Comment:

Well, AFAIK cboos's patch won't work since it's trying to copy the
settings from `os.environ`, but I believe those options will be set in the
mod_python `subprocess_env`. I'll see if it's possible to support this
for [milestone:0.10.1].

--
Ticket URL: <http://trac.edgewall.org/ticket/2661#comment:5>
The Trac Project <http://trac.edgewall.org/>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Trac Tickets" group.
To post to this group, send email to trac-tickets[at]googlegroups.com
To unsubscribe from this group, send email to trac-tickets-unsubscribe[at]googlegroups.com
For more options, visit this group at http://groups.google.se/group/trac-tickets
-~----------~----~----~----~------~----~------~--~---


noreply at edgewall

Sep 20, 2006, 4:25 PM

Post #7 of 7 (792 views)
Permalink
Re: [The Trac Project] #2661: (mod_python) TracError: The environment options "TRAC_ENV" ... are missing. [In reply to]

#2661: (mod_python) TracError: The environment options "TRAC_ENV" ... are missing.
---------------------------------+------------------------------------------
Reporter: schuetze[at]gmx.de | Owner: mgood
Type: defect | Status: new
Priority: normal | Milestone: 0.10.1
Component: mod_python frontend | Version: 0.9.3
Severity: normal | Resolution:
Keywords: needinfo |
---------------------------------+------------------------------------------
Changes (by mgood):

* keywords: => needinfo

Comment:

Well, options set via `SetEnv` are in the `subprocess_env`, but the
`RewriteRule` does not work for me.

I'll attach a patch for reading TRAC_ENV, etc. but since I can't confirm
whether it works with `RewriteRule` I'll hold off on this.

--
Ticket URL: <http://trac.edgewall.org/ticket/2661#comment:6>
The Trac Project <http://trac.edgewall.org/>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Trac Tickets" group.
To post to this group, send email to trac-tickets[at]googlegroups.com
To unsubscribe from this group, send email to trac-tickets-unsubscribe[at]googlegroups.com
For more options, visit this group at http://groups.google.se/group/trac-tickets
-~----------~----~----~----~------~----~------~--~---

Trac tickets RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact lists@gossamer-threads.com
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.