Using MoinMoin with apache + mod_python

mod_python embeds the python interpreter into the apache server. This saves initialization time and the need of forking cgi scripts. It doesn't have the ability to run as different users. It will always run as the main apache user and group. Be sure that your wiki data files are accessible by your apache server!

/!\ mod_python versions 2.7.10, 3.0.4 and 3.1.2b have a bug in apache.resolve_object This bug was reported to the mod_python maintainers and will be fixed in the next releases, as they promised. The sample files use a wrapper to get around this bug, so there is no need to worry.

Deploying MoinMoin with mod_python

Follow the basic apache installation for your operating system as described in other parts of the MoinMoin installation documentation. Don't copy moin.cgi, cause you won't need it. Be sure that the apache process can access the wiki data files (check User and Group in your apache.conf).

Copy the sample moin_modpy.htaccess as .htaccess to the path below which your wiki instance should be found:

cd /usr/local/share/moin
cp wiki/cgi-bin/moin_modpy.htaccess /path/to/your/docroot/.htaccess

Check the .htaccess that the PythonPath matches your installation. It should contain the path where the moin_modpy.py wrapper is installed (Note: the wrapper does not have to be within your DOCROOT). You can also change the name of your instance (<Files wikiname>).

Check sys.path of moin_modpy.py. It needs to find the MoinMoin package (not needed if MoinMoin is installed system wide) and your moin_config.py.

In some cases you need to restart apache after changes to py files used by mod_python. Please refer to the mod_python documentation.

Fixing the mod_python bug

/!\ If you did use the wrapper setup from the previous section, you don't need to do this.

mod_python has a small resolver bug in versions 2.7.10, 3.0.4 and 3.1.2b. The method resolve_object in mod_python/apache.py checks the wrong object, and so the lookup for RequestModPy.run fails. You have two possibilities to live with it: either use the wrapper script moin_modpy.py or fix the bug.

To fix it you need to change the method resolve_object (around line 551 for mod_python 3.1.2b) from

        if silent and not hasattr(module, obj_str):
            return None

to

        if silent and not hasattr(obj, obj_str):
            return None

This bug is currently in all versions of mod_python (2.7.10, 3.0.4, 3.1.2b) and should be fixed in newer mod_python versions (bug and patch are reported to the mod_python development list). Please read the changelog of mod_python to be sure that you have a fixed version, or verify the lines on your own!

Deploying with a fixed mod_python

/!\ This section only works with a fixed mod_python (see previous section)!

Follow the deployment documentation above. Use the special commented out section of moin_modpy.htaccess instead of the default wrapper using part.

Check the PythonPath in the .htaccess that it matches your installation. It should contain the python lib path where the MoinMoin package is stored (not needed if MoinMoin is installed system wide) and the path to your moin_config.py.

The wrapper script moin_modpy.py is not needed, cause the RequestModPy class is used directly by mod_python.

HelpOnInstalling/ApacheWithModPython (last edited 2008-04-17 08:18:16 by localhost)