wiki/server/moin.fcgi
author Thomas Waldmann <tw AT waldmann-edv DOT de>
Sun, 28 Feb 2010 23:49:03 +0100
changeset 5597 ced05deb11ae
parent 5492 e900c097a46b
permissions -rwxr-xr-x
cfg.history_paging: fix grammar/remove performance warning (we don't do that at other places either)
     1 #!/usr/bin/python
     2 # -*- coding: utf-8 -*-
     3 """
     4     MoinMoin - CGI/FCGI Driver script
     5 
     6     @copyright: 2000-2005 by Juergen Hermann <jh@web.de>,
     7                 2008 by MoinMoin:ThomasWaldmann,
     8                 2008 by MoinMoin:FlorianKrupicka,
     9                 2010 by MoinMoin:RadomirDopieralski
    10     @license: GNU GPL, see COPYING for details.
    11 """
    12 
    13 import sys, os
    14 
    15 # a) Configuration of Python's code search path
    16 #    If you already have set up the PYTHONPATH environment variable for the
    17 #    stuff you see below, you don't need to do a1) and a2).
    18 
    19 # a1) Path of the directory where the MoinMoin code package is located.
    20 #     Needed if you installed with --prefix=PREFIX or you didn't use setup.py.
    21 #sys.path.insert(0, 'PREFIX/lib/python2.3/site-packages')
    22 
    23 # a2) Path of the directory where wikiconfig.py / farmconfig.py is located.
    24 #     See wiki/config/... for some sample config files.
    25 #sys.path.insert(0, '/path/to/wikiconfigdir')
    26 #sys.path.insert(0, '/path/to/farmconfigdir')
    27 
    28 # b) Configuration of moin's logging
    29 #    If you have set up MOINLOGGINGCONF environment variable, you don't need this!
    30 #    You also don't need this if you are happy with the builtin defaults.
    31 #    See wiki/config/logging/... for some sample config files.
    32 from MoinMoin import log
    33 #log.load_config('/path/to/logging_configuration_file')
    34 logging = log.getLogger(__name__)
    35 
    36 ## this works around a bug in flup's CGI autodetection (as of flup 1.0.1):
    37 #os.environ['FCGI_FORCE_CGI'] = 'Y' # 'Y' for (slow) CGI, 'N' for FCGI
    38 
    39 # Creating the WSGI application
    40 # use shared=True to have moin serve the builtin static docs
    41 # use shared=False to not have moin serve static docs
    42 # use shared='/my/path/to/htdocs' to serve static docs from that path
    43 from MoinMoin.web.serving import make_application
    44 app = make_application(shared=True)  # <-- adapt here as needed
    45 
    46 # Is fixing the script name needed?
    47 # Use None if your url looks like http://domain/wiki/moin.fcgi
    48 # Use '' if you use rewriting to run at http://domain/
    49 # Use '/mywiki' if you use rewriting to run at http://domain/mywiki/
    50 fix_script_name = None  # <-- adapt here as needed
    51 
    52 if fix_script_name is None:
    53     application = app
    54 else:
    55     def script_name_fixer(env, start):
    56         env['SCRIPT_NAME'] = fix_script_name
    57         return app(env, start)
    58     application = script_name_fixer
    59 
    60 
    61 # CGI with Apache2 on Windows (maybe other combinations also) has trouble with
    62 # URLs of non-ASCII pagenames. Use True to enable middleware that tries to fix.
    63 fix_apache_win32 = False  # <-- adapt here as needed
    64 
    65 if fix_apache_win32:
    66     from werkzeug.contrib.fixers import PathInfoFromRequestUriFix
    67     application = PathInfoFromRequestUriFix(application)
    68 
    69 
    70 ## Choose your server mode (threaded, forking or single-thread)
    71 try:
    72     # v-- adapt here as needed
    73     from flup.server.fcgi import WSGIServer
    74 #    from flup.server.fcgi_fork import WSGIServer
    75 #    from flup.server.fcgi_single import WSGIServer
    76 except ImportError:
    77     logging.warning("No flup-package installed, only basic CGI support is available.")
    78     from MoinMoin.web._fallback_cgi import WSGIServer
    79 
    80 WSGIServer(application).run()
    81