annotate wiki/server/moin.fcgi @ 5489:a68d363312db

a less magic cgi/fcgi driver
author Radomir Dopieralski <moindev@sheep.art.pl>
date Wed, 03 Feb 2010 21:16:18 +0100
parents
children 65bf6cb180b7
rev   line source
5489
a68d363312db a less magic cgi/fcgi driver
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
1 #!/usr/bin/python
a68d363312db a less magic cgi/fcgi driver
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
2 # -*- coding: utf-8 -*-
a68d363312db a less magic cgi/fcgi driver
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
3
a68d363312db a less magic cgi/fcgi driver
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
4 """
a68d363312db a less magic cgi/fcgi driver
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
5 MoinMoin - CGI/FCGI Driver script
a68d363312db a less magic cgi/fcgi driver
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
6
a68d363312db a less magic cgi/fcgi driver
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
7 @copyright: 2000-2005 by Juergen Hermann <jh@web.de>,
a68d363312db a less magic cgi/fcgi driver
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
8 2008 by MoinMoin:ThomasWaldmann,
a68d363312db a less magic cgi/fcgi driver
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
9 2008 by MoinMoin:FlorianKrupicka
a68d363312db a less magic cgi/fcgi driver
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
10 2010 by MoinMoin:RadomirDopieralski
a68d363312db a less magic cgi/fcgi driver
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
11 @license: GNU GPL, see COPYING for details.
a68d363312db a less magic cgi/fcgi driver
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
12 """
a68d363312db a less magic cgi/fcgi driver
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
13
a68d363312db a less magic cgi/fcgi driver
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
14 import sys, os
a68d363312db a less magic cgi/fcgi driver
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
15
a68d363312db a less magic cgi/fcgi driver
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
16 # a) Configuration of Python's code search path
a68d363312db a less magic cgi/fcgi driver
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
17 # If you already have set up the PYTHONPATH environment variable for the
a68d363312db a less magic cgi/fcgi driver
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
18 # stuff you see below, you don't need to do a1) and a2).
a68d363312db a less magic cgi/fcgi driver
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
19
a68d363312db a less magic cgi/fcgi driver
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
20 # a1) Path of the directory where the MoinMoin code package is located.
a68d363312db a less magic cgi/fcgi driver
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
21 # Needed if you installed with --prefix=PREFIX or you didn't use setup.py.
a68d363312db a less magic cgi/fcgi driver
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
22 #sys.path.insert(0, 'PREFIX/lib/python2.3/site-packages')
a68d363312db a less magic cgi/fcgi driver
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
23
a68d363312db a less magic cgi/fcgi driver
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
24 # a2) Path of the directory where wikiconfig.py / farmconfig.py is located.
a68d363312db a less magic cgi/fcgi driver
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
25 # See wiki/config/... for some sample config files.
a68d363312db a less magic cgi/fcgi driver
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
26 #sys.path.insert(0, '/path/to/wikiconfigdir')
a68d363312db a less magic cgi/fcgi driver
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
27 #sys.path.insert(0, '/path/to/farmconfigdir')
a68d363312db a less magic cgi/fcgi driver
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
28
a68d363312db a less magic cgi/fcgi driver
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
29 # b) Configuration of moin's logging
a68d363312db a less magic cgi/fcgi driver
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
30 # If you have set up MOINLOGGINGCONF environment variable, you don't need this!
a68d363312db a less magic cgi/fcgi driver
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
31 # You also don't need this if you are happy with the builtin defaults.
a68d363312db a less magic cgi/fcgi driver
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
32 # See wiki/config/logging/... for some sample config files.
a68d363312db a less magic cgi/fcgi driver
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
33 from MoinMoin import log
a68d363312db a less magic cgi/fcgi driver
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
34 #log.load_config('/path/to/logging_configuration_file')
a68d363312db a less magic cgi/fcgi driver
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
35 logging = log.getLogger(__name__)
a68d363312db a less magic cgi/fcgi driver
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
36
a68d363312db a less magic cgi/fcgi driver
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
37 ## this works around a bug in flup's CGI autodetection (as of flup 1.0.1):
a68d363312db a less magic cgi/fcgi driver
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
38 #os.environ['FCGI_FORCE_CGI'] = 'Y' # 'Y' for (slow) CGI, 'N' for FCGI
a68d363312db a less magic cgi/fcgi driver
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
39
a68d363312db a less magic cgi/fcgi driver
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
40 # Creating the WSGI application
a68d363312db a less magic cgi/fcgi driver
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
41 # use shared=True to have moin serve the builtin static docs
a68d363312db a less magic cgi/fcgi driver
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
42 # use shared=False to not have moin serve static docs
a68d363312db a less magic cgi/fcgi driver
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
43 # use shared='/my/path/to/htdocs' to serve static docs from that path
a68d363312db a less magic cgi/fcgi driver
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
44 from MoinMoin.web.serving import make_application
a68d363312db a less magic cgi/fcgi driver
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
45 application = make_application(shared=True)
a68d363312db a less magic cgi/fcgi driver
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
46
a68d363312db a less magic cgi/fcgi driver
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
47 ## Uncomment this if you need to set the SCRIPT_NAME:
a68d363312db a less magic cgi/fcgi driver
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
48 #def application(env, start):
a68d363312db a less magic cgi/fcgi driver
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
49 # env['SCRIPT_NAME'] = ''
a68d363312db a less magic cgi/fcgi driver
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
50 # return application(env, start)
a68d363312db a less magic cgi/fcgi driver
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
51
a68d363312db a less magic cgi/fcgi driver
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
52 ## Choose your server mode (threaded, forking or single-thread)
a68d363312db a less magic cgi/fcgi driver
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
53 try:
a68d363312db a less magic cgi/fcgi driver
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
54 from flup.server.fcgi import WSGIServer
a68d363312db a less magic cgi/fcgi driver
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
55 # from flup.server.fcgi_fork import WSGIServer
a68d363312db a less magic cgi/fcgi driver
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
56 # from flup.server.fcgi_single import WSGIServer
a68d363312db a less magic cgi/fcgi driver
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
57 except ImportError:
a68d363312db a less magic cgi/fcgi driver
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
58 logging.warning("No flup-package installed, only basic CGI "
a68d363312db a less magic cgi/fcgi driver
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
59 "support is available.")
a68d363312db a less magic cgi/fcgi driver
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
60 from MoinMoin.web._fallback_cgi import WSGIServer
a68d363312db a less magic cgi/fcgi driver
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
61
a68d363312db a less magic cgi/fcgi driver
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
62 WSGIServer(application).run()