changeset 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 cded5f776bc1
children ca71e01d845b
files wiki/server/moin.fcgi
diffstat 1 files changed, 62 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wiki/server/moin.fcgi	Wed Feb 03 21:16:18 2010 +0100
@@ -0,0 +1,62 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
+
+"""
+    MoinMoin - CGI/FCGI Driver script
+
+    @copyright: 2000-2005 by Juergen Hermann <jh@web.de>,
+                2008 by MoinMoin:ThomasWaldmann,
+                2008 by MoinMoin:FlorianKrupicka
+                2010 by MoinMoin:RadomirDopieralski
+    @license: GNU GPL, see COPYING for details.
+"""
+
+import sys, os
+
+# a) Configuration of Python's code search path
+#    If you already have set up the PYTHONPATH environment variable for the
+#    stuff you see below, you don't need to do a1) and a2).
+
+# a1) Path of the directory where the MoinMoin code package is located.
+#     Needed if you installed with --prefix=PREFIX or you didn't use setup.py.
+#sys.path.insert(0, 'PREFIX/lib/python2.3/site-packages')
+
+# a2) Path of the directory where wikiconfig.py / farmconfig.py is located.
+#     See wiki/config/... for some sample config files.
+#sys.path.insert(0, '/path/to/wikiconfigdir')
+#sys.path.insert(0, '/path/to/farmconfigdir')
+
+# b) Configuration of moin's logging
+#    If you have set up MOINLOGGINGCONF environment variable, you don't need this!
+#    You also don't need this if you are happy with the builtin defaults.
+#    See wiki/config/logging/... for some sample config files.
+from MoinMoin import log
+#log.load_config('/path/to/logging_configuration_file')
+logging = log.getLogger(__name__)
+
+## this works around a bug in flup's CGI autodetection (as of flup 1.0.1):
+#os.environ['FCGI_FORCE_CGI'] = 'Y' # 'Y' for (slow) CGI, 'N' for FCGI
+
+# Creating the WSGI application
+# use shared=True to have moin serve the builtin static docs
+# use shared=False to not have moin serve static docs
+# use shared='/my/path/to/htdocs' to serve static docs from that path
+from MoinMoin.web.serving import make_application
+application = make_application(shared=True)
+
+## Uncomment this if you need to set the SCRIPT_NAME:
+#def application(env, start):
+#    env['SCRIPT_NAME'] = ''
+#    return application(env, start)
+
+## Choose your server mode (threaded, forking or single-thread)
+try:
+    from flup.server.fcgi import WSGIServer
+#    from flup.server.fcgi_fork import WSGIServer
+#    from flup.server.fcgi_single import WSGIServer
+except ImportError:
+    logging.warning("No flup-package installed, only basic CGI "
+                    "support is available.")
+    from MoinMoin.web._fallback_cgi import WSGIServer
+
+WSGIServer(application).run()