changeset 5555:0cf43758feab

merged main
author Reimar Bauer <rb.proj AT googlemail DOT com>
date Sat, 20 Feb 2010 16:52:38 +0100
parents 0dea6dbebafb (current diff) 7d27d4c3f44b (diff)
children b99c12a9b82c
files
diffstat 3 files changed, 41 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/support/flup/NOTES.moin	Sat Feb 20 16:52:02 2010 +0100
+++ b/MoinMoin/support/flup/NOTES.moin	Sat Feb 20 16:52:38 2010 +0100
@@ -7,6 +7,9 @@
 hg clone -r 0266cedb313b http://hg.saddi.com/flup-server
 # this is flup 1.0.2+, minimum requirement for moin is 1.0.2.
 
+We fixed some CGI/FCGI autodetection/forcing related problem on win32 locally
+(and submitted a bug about it, see http://trac.saddi.com/flup/ticket/51 ).
+
 Thanks to Allan Saddi <allan@saddi.com> for writing flup and to
 the unnamed contributor <tv@inoi.fi> for the single-thread patch.
 
--- a/MoinMoin/support/flup/server/fcgi_base.py	Sat Feb 20 16:52:02 2010 +0100
+++ b/MoinMoin/support/flup/server/fcgi_base.py	Sat Feb 20 16:52:38 2010 +0100
@@ -1000,27 +1000,40 @@
                 }
 
     def _setupSocket(self):
-        if self._bindAddress is None: # Run as a normal FastCGI?
-            isFCGI = True
-
-            sock = socket.fromfd(FCGI_LISTENSOCK_FILENO, socket.AF_INET,
-                                 socket.SOCK_STREAM)
-            try:
-                sock.getpeername()
-            except socket.error, e:
-                if e[0] == errno.ENOTSOCK:
-                    # Not a socket, assume CGI context.
-                    isFCGI = False
-                elif e[0] != errno.ENOTCONN:
-                    raise
+        if self._bindAddress is None:
+            # Run as a normal FastCGI?
 
             # FastCGI/CGI discrimination is broken on Mac OS X.
             # Set the environment variable FCGI_FORCE_CGI to "Y" or "y"
             # if you want to run your app as a simple CGI. (You can do
             # this with Apache's mod_env [not loaded by default in OS X
             # client, ha ha] and the SetEnv directive.)
-            if not isFCGI or self.forceCGI or \
-               os.environ.get('FCGI_FORCE_CGI', 'N').upper().startswith('Y'):
+            forceCGI = self.forceCGI or \
+               os.environ.get('FCGI_FORCE_CGI', 'N').upper().startswith('Y')
+
+            if forceCGI:
+                isFCGI = False
+            else:
+                if not hasattr(socket, 'fromfd'):
+                    # can happen on win32, no socket.fromfd there!
+                    raise ValueError(
+                        'If you want FCGI, please create an external FCGI server '
+                        'by providing a valid bindAddress. '
+                        'If you want CGI, please force CGI operation. Use '
+                        'FCGI_FORCE_CGI=Y environment or forceCGI parameter.')
+                sock = socket.fromfd(FCGI_LISTENSOCK_FILENO, socket.AF_INET,
+                                     socket.SOCK_STREAM)
+                isFCGI = True
+                try:
+                    sock.getpeername()
+                except socket.error, e:
+                    if e[0] == errno.ENOTSOCK:
+                        # Not a socket, assume CGI context.
+                        isFCGI = False
+                    elif e[0] != errno.ENOTCONN:
+                        raise
+
+            if not isFCGI:
                 req = self.cgirequest_class(self)
                 req.run()
                 sys.exit(0)
--- a/wiki/server/moin.fcgi	Sat Feb 20 16:52:02 2010 +0100
+++ b/wiki/server/moin.fcgi	Sat Feb 20 16:52:38 2010 +0100
@@ -57,6 +57,16 @@
         return app(env, start)
     application = script_name_fixer
 
+
+# CGI with Apache2 on Windows (maybe other combinations also) has trouble with
+# URLs of non-ASCII pagenames. Use True to enable middleware that tries to fix.
+fix_apache_win32 = False  # <-- adapt here as needed
+
+if fix_apache_win32:
+    from werkzeug.contrib.fixers import PathInfoFromRequestUriFix
+    application = PathInfoFromRequestUriFix(application)
+
+
 ## Choose your server mode (threaded, forking or single-thread)
 try:
     # v-- adapt here as needed