Mercurial > moin > 1.9
changeset 2975:ea78a739b5ad
imported patch fix-modpython-patch (port from 1.6)
author | Thomas Waldmann <tw AT waldmann-edv DOT de> |
---|---|
date | Sat, 05 Jan 2008 21:46:35 +0100 |
parents | bc61a0470fd9 |
children | 9314cf657f07 |
files | MoinMoin/request/request_modpython.py MoinMoin/server/server_modpython.py wiki/server/moinmodpy.py |
diffstat | 3 files changed, 71 insertions(+), 14 deletions(-) [+] |
line wrap: on
line diff
--- a/MoinMoin/request/request_modpython.py Sat Jan 05 21:30:45 2008 +0100 +++ b/MoinMoin/request/request_modpython.py Sat Jan 05 21:46:35 2008 +0100 @@ -12,7 +12,7 @@ class Request(RequestBase): """ specialized on mod_python requests """ - def __init__(self, req): + def __init__(self, req, properties={}): """ Saves mod_pythons request and sets basic variables using the req.subprocess_env, cause this provides a standard way to access the values we need here. @@ -33,7 +33,7 @@ else: env = req.subprocess_env self._setup_vars_from_std_env(env) - RequestBase.__init__(self) + RequestBase.__init__(self, properties) except Exception, err: self.fail(err) @@ -84,7 +84,9 @@ form = util.FieldStorage(self.mpyreq) args = {} - for key in form: + + # You cannot get rid of .keys() here + for key in form.keys(): if key is None: continue values = form[key]
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/MoinMoin/server/server_modpython.py Sat Jan 05 21:46:35 2008 +0100 @@ -0,0 +1,49 @@ +# -*- coding: iso-8859-1 -*- +""" + MoinMoin.server.server_modpython + + This is not really a server, it is just so that modpython stuff + (the real server is likely Apache2) fits the model we have for + Twisted and standalone server. + + Minimal usage: + + from MoinMoin.server.server_modpython import CgiConfig, run + + class Config(CgiConfig): + pass + + run(Config) + + See more options in CgiConfig class. + + @copyright: 2006 MoinMoin:ThomasWaldmann + @license: GNU GPL, see COPYING for details. +""" + +from MoinMoin.server import Config +from MoinMoin.request import request_modpython + +# Set threads flag, so other code can use proper locking. +# TODO: It seems that modpy does not use threads, so we don't need to +# set it here. Do we have another method to check this? +from MoinMoin import config +config.use_threads = 1 +del config + +# Server globals +config = None + +class ModpythonConfig(Config): + """ Set up default server """ + + logPath = None + properties = {} + + # Set up log handler to log to apache log! + +def modpythonHandler(request, ConfigClass=ModpythonConfig): + config = ConfigClass() + moinreq = request_modpython.Request(request, config.properties) + return moinreq.run(request) +
--- a/wiki/server/moinmodpy.py Sat Jan 05 21:30:45 2008 +0100 +++ b/wiki/server/moinmodpy.py Sat Jan 05 21:46:35 2008 +0100 @@ -48,17 +48,23 @@ ## import os ## os.environ['MOIN_DEBUG'] = '1' -# Set threads flag, so other code can use proper locking. -# TODO: It seems that modpy does not use threads, so we don't need to -# set it here. Do we have another method to check this? -from MoinMoin import config -config.use_threads = 1 -del config +# Simple way +#from MoinMoin.server.server_modpython import modpythonHandler as handler + +# Complex way +from MoinMoin.server.server_modpython import ModpythonConfig, modpythonHandler + +class MyConfig(ModpythonConfig): + """ Set up local server-specific stuff here """ - -from MoinMoin.request import request_modpython + # Make sure moin will have permission to write to this file! + # Otherwise it will cause a server error. + logPath = "/var/log/apache2/moinlog" + + # Properties + # Allow overriding any request property by the value defined in + # this dict e.g properties = {'script_name': '/mywiki'}. + ## properties = {} def handler(request): - moinreq = request_modpython.Request(request) - return moinreq.run(request) - + return modpythonHandler(request, MyConfig)