annotate wiki/server/moin.fcgi @ 6133:a6283e189869 tip

fixup: remove nonexisting passlib.utils._blowfish this was removed by the passlib 1.7.1 upgrade.
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Thu, 01 Jun 2017 18:10:19 +0200
parents d811122349fb
children
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 MoinMoin - CGI/FCGI Driver script
a68d363312db a less magic cgi/fcgi driver
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
5
a68d363312db a less magic cgi/fcgi driver
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
6 @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
7 2008 by MoinMoin:ThomasWaldmann,
5491
65bf6cb180b7 moin.fcgi: fix recursion error and some minor cosmetics
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5489
diff changeset
8 2008 by MoinMoin:FlorianKrupicka,
5489
a68d363312db a less magic cgi/fcgi driver
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
9 2010 by MoinMoin:RadomirDopieralski
a68d363312db a less magic cgi/fcgi driver
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
10 @license: GNU GPL, see COPYING for details.
a68d363312db a less magic cgi/fcgi driver
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
11 """
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 import sys, os
a68d363312db a less magic cgi/fcgi driver
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
14
a68d363312db a less magic cgi/fcgi driver
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
15 # a) Configuration of Python's code search path
a68d363312db a less magic cgi/fcgi driver
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
16 # 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
17 # 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
18
a68d363312db a less magic cgi/fcgi driver
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
19 # 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
20 # Needed if you installed with --prefix=PREFIX or you didn't use setup.py.
6092
d811122349fb trivial changes to comments: replace "python2.3" with "python2.7", minor rewording of comments
RogerHaase
parents: 5553
diff changeset
21 #sys.path.insert(0, 'PREFIX/lib/python2.7/site-packages')
5489
a68d363312db a less magic cgi/fcgi driver
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
22
a68d363312db a less magic cgi/fcgi driver
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
23 # 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
24 # See wiki/config/... for some sample config files.
a68d363312db a less magic cgi/fcgi driver
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
25 #sys.path.insert(0, '/path/to/wikiconfigdir')
a68d363312db a less magic cgi/fcgi driver
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
26 #sys.path.insert(0, '/path/to/farmconfigdir')
a68d363312db a less magic cgi/fcgi driver
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
27
a68d363312db a less magic cgi/fcgi driver
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
28 # b) Configuration of moin's logging
a68d363312db a less magic cgi/fcgi driver
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
29 # 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
30 # 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
31 # 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
32 from MoinMoin import log
a68d363312db a less magic cgi/fcgi driver
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
33 #log.load_config('/path/to/logging_configuration_file')
a68d363312db a less magic cgi/fcgi driver
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
34 logging = log.getLogger(__name__)
a68d363312db a less magic cgi/fcgi driver
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
35
a68d363312db a less magic cgi/fcgi driver
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
36 ## 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
37 #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
38
a68d363312db a less magic cgi/fcgi driver
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
39 # Creating the WSGI application
a68d363312db a less magic cgi/fcgi driver
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
40 # 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
41 # 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
42 # 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
43 from MoinMoin.web.serving import make_application
5492
e900c097a46b moin.fcgi: fix recursion error, try 2
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5491
diff changeset
44 app = make_application(shared=True) # <-- adapt here as needed
5489
a68d363312db a less magic cgi/fcgi driver
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
45
5492
e900c097a46b moin.fcgi: fix recursion error, try 2
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5491
diff changeset
46 # Is fixing the script name needed?
e900c097a46b moin.fcgi: fix recursion error, try 2
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5491
diff changeset
47 # Use None if your url looks like http://domain/wiki/moin.fcgi
e900c097a46b moin.fcgi: fix recursion error, try 2
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5491
diff changeset
48 # Use '' if you use rewriting to run at http://domain/
e900c097a46b moin.fcgi: fix recursion error, try 2
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5491
diff changeset
49 # Use '/mywiki' if you use rewriting to run at http://domain/mywiki/
e900c097a46b moin.fcgi: fix recursion error, try 2
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5491
diff changeset
50 fix_script_name = None # <-- adapt here as needed
e900c097a46b moin.fcgi: fix recursion error, try 2
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5491
diff changeset
51
e900c097a46b moin.fcgi: fix recursion error, try 2
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5491
diff changeset
52 if fix_script_name is None:
e900c097a46b moin.fcgi: fix recursion error, try 2
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5491
diff changeset
53 application = app
e900c097a46b moin.fcgi: fix recursion error, try 2
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5491
diff changeset
54 else:
e900c097a46b moin.fcgi: fix recursion error, try 2
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5491
diff changeset
55 def script_name_fixer(env, start):
e900c097a46b moin.fcgi: fix recursion error, try 2
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5491
diff changeset
56 env['SCRIPT_NAME'] = fix_script_name
e900c097a46b moin.fcgi: fix recursion error, try 2
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5491
diff changeset
57 return app(env, start)
e900c097a46b moin.fcgi: fix recursion error, try 2
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5491
diff changeset
58 application = script_name_fixer
5489
a68d363312db a less magic cgi/fcgi driver
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
59
5553
7d27d4c3f44b moin.fcgi: add fixer middleware for apache2/win32
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5492
diff changeset
60
7d27d4c3f44b moin.fcgi: add fixer middleware for apache2/win32
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5492
diff changeset
61 # CGI with Apache2 on Windows (maybe other combinations also) has trouble with
7d27d4c3f44b moin.fcgi: add fixer middleware for apache2/win32
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5492
diff changeset
62 # URLs of non-ASCII pagenames. Use True to enable middleware that tries to fix.
7d27d4c3f44b moin.fcgi: add fixer middleware for apache2/win32
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5492
diff changeset
63 fix_apache_win32 = False # <-- adapt here as needed
7d27d4c3f44b moin.fcgi: add fixer middleware for apache2/win32
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5492
diff changeset
64
7d27d4c3f44b moin.fcgi: add fixer middleware for apache2/win32
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5492
diff changeset
65 if fix_apache_win32:
7d27d4c3f44b moin.fcgi: add fixer middleware for apache2/win32
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5492
diff changeset
66 from werkzeug.contrib.fixers import PathInfoFromRequestUriFix
7d27d4c3f44b moin.fcgi: add fixer middleware for apache2/win32
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5492
diff changeset
67 application = PathInfoFromRequestUriFix(application)
7d27d4c3f44b moin.fcgi: add fixer middleware for apache2/win32
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5492
diff changeset
68
7d27d4c3f44b moin.fcgi: add fixer middleware for apache2/win32
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5492
diff changeset
69
5489
a68d363312db a less magic cgi/fcgi driver
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
70 ## 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
71 try:
5492
e900c097a46b moin.fcgi: fix recursion error, try 2
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5491
diff changeset
72 # v-- adapt here as needed
5489
a68d363312db a less magic cgi/fcgi driver
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
73 from flup.server.fcgi import WSGIServer
a68d363312db a less magic cgi/fcgi driver
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
74 # from flup.server.fcgi_fork import WSGIServer
a68d363312db a less magic cgi/fcgi driver
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
75 # from flup.server.fcgi_single import WSGIServer
a68d363312db a less magic cgi/fcgi driver
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
76 except ImportError:
5491
65bf6cb180b7 moin.fcgi: fix recursion error and some minor cosmetics
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5489
diff changeset
77 logging.warning("No flup-package installed, only basic CGI support is available.")
5489
a68d363312db a less magic cgi/fcgi driver
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
78 from MoinMoin.web._fallback_cgi import WSGIServer
a68d363312db a less magic cgi/fcgi driver
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
79
a68d363312db a less magic cgi/fcgi driver
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
80 WSGIServer(application).run()
5491
65bf6cb180b7 moin.fcgi: fix recursion error and some minor cosmetics
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5489
diff changeset
81