annotate MoinMoin/server/server_modpython.py @ 3105:80e1a910a2f1

make logging more configurable and flexible, packages/modules shall call MoinMoin.server.getLogger
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Sat, 23 Feb 2008 21:43:47 +0100
parents 103fd9035d50
children cd43bbf56c33
rev   line source
2975
ea78a739b5ad imported patch fix-modpython-patch (port from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
1 # -*- coding: iso-8859-1 -*-
ea78a739b5ad imported patch fix-modpython-patch (port from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
2 """
ea78a739b5ad imported patch fix-modpython-patch (port from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
3 MoinMoin.server.server_modpython
ea78a739b5ad imported patch fix-modpython-patch (port from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
4
ea78a739b5ad imported patch fix-modpython-patch (port from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
5 This is not really a server, it is just so that modpython stuff
ea78a739b5ad imported patch fix-modpython-patch (port from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
6 (the real server is likely Apache2) fits the model we have for
ea78a739b5ad imported patch fix-modpython-patch (port from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
7 Twisted and standalone server.
ea78a739b5ad imported patch fix-modpython-patch (port from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
8
ea78a739b5ad imported patch fix-modpython-patch (port from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
9 Minimal usage:
ea78a739b5ad imported patch fix-modpython-patch (port from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
10
ea78a739b5ad imported patch fix-modpython-patch (port from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
11 from MoinMoin.server.server_modpython import CgiConfig, run
3070
ed1a433803c6 PEP8 fixes
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2975
diff changeset
12
2975
ea78a739b5ad imported patch fix-modpython-patch (port from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
13 class Config(CgiConfig):
ea78a739b5ad imported patch fix-modpython-patch (port from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
14 pass
ea78a739b5ad imported patch fix-modpython-patch (port from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
15
ea78a739b5ad imported patch fix-modpython-patch (port from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
16 run(Config)
3070
ed1a433803c6 PEP8 fixes
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2975
diff changeset
17
2975
ea78a739b5ad imported patch fix-modpython-patch (port from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
18 See more options in CgiConfig class.
ea78a739b5ad imported patch fix-modpython-patch (port from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
19
ea78a739b5ad imported patch fix-modpython-patch (port from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
20 @copyright: 2006 MoinMoin:ThomasWaldmann
ea78a739b5ad imported patch fix-modpython-patch (port from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
21 @license: GNU GPL, see COPYING for details.
ea78a739b5ad imported patch fix-modpython-patch (port from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
22 """
ea78a739b5ad imported patch fix-modpython-patch (port from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
23
ea78a739b5ad imported patch fix-modpython-patch (port from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
24 from MoinMoin.server import Config
ea78a739b5ad imported patch fix-modpython-patch (port from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
25 from MoinMoin.request import request_modpython
ea78a739b5ad imported patch fix-modpython-patch (port from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
26
ea78a739b5ad imported patch fix-modpython-patch (port from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
27 # Set threads flag, so other code can use proper locking.
ea78a739b5ad imported patch fix-modpython-patch (port from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
28 # TODO: It seems that modpy does not use threads, so we don't need to
ea78a739b5ad imported patch fix-modpython-patch (port from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
29 # set it here. Do we have another method to check this?
ea78a739b5ad imported patch fix-modpython-patch (port from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
30 from MoinMoin import config
ea78a739b5ad imported patch fix-modpython-patch (port from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
31 config.use_threads = 1
ea78a739b5ad imported patch fix-modpython-patch (port from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
32 del config
ea78a739b5ad imported patch fix-modpython-patch (port from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
33
ea78a739b5ad imported patch fix-modpython-patch (port from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
34 # Server globals
ea78a739b5ad imported patch fix-modpython-patch (port from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
35 config = None
ea78a739b5ad imported patch fix-modpython-patch (port from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
36
ea78a739b5ad imported patch fix-modpython-patch (port from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
37 class ModpythonConfig(Config):
ea78a739b5ad imported patch fix-modpython-patch (port from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
38 """ Set up default server """
ea78a739b5ad imported patch fix-modpython-patch (port from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
39 properties = {}
3070
ed1a433803c6 PEP8 fixes
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2975
diff changeset
40
2975
ea78a739b5ad imported patch fix-modpython-patch (port from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
41 # Set up log handler to log to apache log!
ea78a739b5ad imported patch fix-modpython-patch (port from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
42
ea78a739b5ad imported patch fix-modpython-patch (port from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
43 def modpythonHandler(request, ConfigClass=ModpythonConfig):
ea78a739b5ad imported patch fix-modpython-patch (port from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
44 config = ConfigClass()
ea78a739b5ad imported patch fix-modpython-patch (port from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
45 moinreq = request_modpython.Request(request, config.properties)
ea78a739b5ad imported patch fix-modpython-patch (port from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
46 return moinreq.run(request)
ea78a739b5ad imported patch fix-modpython-patch (port from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
47