Description
A wiki that's installed more than one dir deep (say /project/mywiki) does not work with mod_python, but works perfectly well with CGI.
Steps to reproduce
Try to run a wiki from url that contain several parts, like 'a/b/c'. The wiki root url should be in this case 'a/b/c' and url to FrontPage is '/a/b/c/FrontPage'.
Example
- Serving it up via mod_python, when the wiki root problem gets solved
{{{<Location /a/b/c>
SetHandler python-program PythonPath "['/var/www/test/mywiki']+sys.path" PythonHandler MoinMoin.request::RequestModPy.run
</Location>}}}
Details
MoinMoin Version |
1.3.4 |
OS and Version |
CentOS 4, Mac OS X 10.3.7 |
Python Version |
2.3.4 |
Server Setup |
Apache 2.0.52 |
Server Details |
mod_python-3.1.3-5.1 |
Workaround
- Use path like 'a_b_c'
- Use rewrite rules to map 'a/b/c' to 'c'
- Use FastCGI (can be faster on some cases)
- Use CGI
Discussion
The problem is that mod python use the first component of the url as the script name, and use the other parts as path_info. So request to 'a/b/c/FrontPage' will be parsed as request page 'b/c/FrontPage' of wiki '/a'. Seems that mod-python does not use the location directive properly, and we don't have access to this information from moin. Without this data, we can't split the url properly.
Checking Apache docs and asking in #apache tell us that its not realy defined how the script name and path info should be parsed when using <location> directive. So its not a bug in mod_python, but just a ambiguous configuration.
The solution can be to set a variable in apache conf, then use that variable to set the root of the wiki. Here is a patch to fix this problem. Try to use it and report on the results:
1 * looking for arch@arch.thinkmo.de--2003-archives/moin--main--1.3--patch-704 to compare with
2 * comparing to arch@arch.thinkmo.de--2003-archives/moin--main--1.3--patch-704
3 M MoinMoin/request.py
4
5 * modified files
6
7 --- orig/MoinMoin/request.py
8 +++ mod/MoinMoin/request.py
9 @@ -1699,12 +1699,41 @@
10 env=dict(req.subprocess_env)
11 else:
12 env=req.subprocess_env
13 + # Must be called BEFORE _setup_vars_from_std_env
14 + self.fixScriptNameAndPathInfo(env)
15 self._setup_vars_from_std_env(env)
16 RequestBase.__init__(self)
17
18 except error.FatalError, err:
19 self.fail(err)
20
21 + def fixScriptNameAndPathInfo(self, env):
22 + """ Set script_name and path_info using httpd config
23 +
24 + When configuring using Apache <location> directive and path
25 + like /a/b/c, the only way to set correct script_name and
26 + path_info is to pass the required script_name using
27 + PythonOption. See example configuration:
28 +
29 + <Location /url/to/mywiki>
30 + PythonOption Location /url/to/mywiki
31 + </location>
32 +
33 + Must be called before self._setup_vars_from_std_env
34 + """
35 + location = self.mpyreq.get_options().get('Location')
36 + if location is not None:
37 + restoredURI = env['SCRIPT_NAME'] + env['PATH_INFO']
38 + if not restoredURI.startswith(location):
39 + message = '''Wrong "PythonOption Location %s".
40 +
41 +PythonOption Location value should match Apache Location directive. Fix
42 +and restart Apache.
43 +''' % location
44 + raise error.ConfigurationError(message)
45 + env['SCRIPT_NAME'] = location
46 + env['PATH_INFO'] = restoredURI[len(location):]
47 +
48 def setup_args(self, form=None):
49 """ Sets up args by using mod_python.util.FieldStorage, which
50 is different to cgi.FieldStorage. So we need a separate
To use, apply the patch and add the root of your wiki your Apache config:
<Location /url/to/mywiki> # Must match the location! PythonOption Location /url/to/mywiki Other modpy options here... </Location>
- Hi, i also meet this bug when using IIS (using moin.cgi, Moin version 1.9.1). Could you please tell me how to fix it?
You should apply the patch above (modpy_script.patch) and add providing of mod_python option Location with url path to wiki. — Captain Obvious 2010-02-11 13:59:02
- How is a stone-age bug report and mod-python related to IIS and current moin?
Plan
- Priority:
Assigned to: NirSoffer
- Status: fixed in patch-850