Commits

Robert Brewer  committed ab1af6b

Fix for #803 (run CP under Google App Engine).

  • Participants
  • Parent commits ad9b5a8

Comments (0)

Files changed (5)

File cherrypy/_cprequest.py

                                           # FieldStorage only recognizes POST.
                                           environ={'REQUEST_METHOD': "POST"},
                                           keep_blank_values=1)
-        except http.MaxSizeExceeded:
-            # Post data is too big
-            raise cherrypy.HTTPError(413)
+        except Exception, e:
+            if e.__class__.__name__ == 'MaxSizeExceeded':
+                # Post data is too big
+                raise cherrypy.HTTPError(413)
+            else:
+                raise
         
         # Note that, if headers['Content-Type'] is multipart/*,
         # then forms.file will not exist; instead, each form[key]

File cherrypy/_cpserver.py

         if httpserver is None:
             httpserver = self.instance
         if httpserver is None:
-            from cherrypy import _cpwsgi
-            httpserver = _cpwsgi.CPWSGIServer()
+            from cherrypy import _cpwsgi_server
+            httpserver = _cpwsgi_server.CPWSGIServer()
         if isinstance(httpserver, basestring):
             httpserver = attributes(httpserver)()
         

File cherrypy/_cpwsgi.py

 import sys as _sys
 
 import cherrypy as _cherrypy
-from cherrypy import _cperror, wsgiserver
+from cherrypy import _cperror
 from cherrypy.lib import http as _http
 
 
             bucket = self.config.setdefault(name, {})
             bucket[arg] = v
 
-
-
-#                            Server components                            #
-
-
-class CPHTTPRequest(wsgiserver.HTTPRequest):
-    
-    def __init__(self, sendall, environ, wsgi_app):
-        s = _cherrypy.server
-        self.max_request_header_size = s.max_request_header_size or 0
-        self.max_request_body_size = s.max_request_body_size or 0
-        wsgiserver.HTTPRequest.__init__(self, sendall, environ, wsgi_app)
-
-
-class CPHTTPConnection(wsgiserver.HTTPConnection):
-    
-    RequestHandlerClass = CPHTTPRequest
-
-
-class CPWSGIServer(wsgiserver.CherryPyWSGIServer):
-    """Wrapper for wsgiserver.CherryPyWSGIServer.
-    
-    wsgiserver has been designed to not reference CherryPy in any way,
-    so that it can be used in other frameworks and applications. Therefore,
-    we wrap it here, so we can set our own mount points from cherrypy.tree
-    and apply some attributes from config -> cherrypy.server -> wsgiserver.
-    """
-    
-    ConnectionClass = CPHTTPConnection
-    
-    def __init__(self):
-        server = _cherrypy.server
-        sockFile = server.socket_file
-        if sockFile:
-            bind_addr = sockFile
-        else:
-            bind_addr = (server.socket_host, server.socket_port)
-        
-        s = wsgiserver.CherryPyWSGIServer
-        s.__init__(self, bind_addr, _cherrypy.tree,
-                   server.thread_pool,
-                   server.socket_host,
-                   request_queue_size = server.socket_queue_size,
-                   timeout = server.socket_timeout,
-                   shutdown_timeout = server.shutdown_timeout,
-                   )
-        self.protocol = server.protocol_version
-        self.nodelay = server.nodelay
-        self.ssl_certificate = server.ssl_certificate
-        self.ssl_private_key = server.ssl_private_key
-

File cherrypy/_cpwsgi_server.py

+"""WSGI server interface (see PEP 333). This adds some CP-specific bits to
+the framework-agnostic wsgiserver package.
+"""
+
+import cherrypy
+from cherrypy import wsgiserver
+
+
+class CPHTTPRequest(wsgiserver.HTTPRequest):
+    
+    def __init__(self, sendall, environ, wsgi_app):
+        s = cherrypy.server
+        self.max_request_header_size = s.max_request_header_size or 0
+        self.max_request_body_size = s.max_request_body_size or 0
+        wsgiserver.HTTPRequest.__init__(self, sendall, environ, wsgi_app)
+
+
+class CPHTTPConnection(wsgiserver.HTTPConnection):
+    
+    RequestHandlerClass = CPHTTPRequest
+
+
+class CPWSGIServer(wsgiserver.CherryPyWSGIServer):
+    """Wrapper for wsgiserver.CherryPyWSGIServer.
+    
+    wsgiserver has been designed to not reference CherryPy in any way,
+    so that it can be used in other frameworks and applications. Therefore,
+    we wrap it here, so we can set our own mount points from cherrypy.tree
+    and apply some attributes from config -> cherrypy.server -> wsgiserver.
+    """
+    
+    ConnectionClass = CPHTTPConnection
+    
+    def __init__(self):
+        server = cherrypy.server
+        sockFile = server.socket_file
+        if sockFile:
+            bind_addr = sockFile
+        else:
+            bind_addr = (server.socket_host, server.socket_port)
+        
+        s = wsgiserver.CherryPyWSGIServer
+        s.__init__(self, bind_addr, cherrypy.tree,
+                   server.thread_pool,
+                   server.socket_host,
+                   request_queue_size = server.socket_queue_size,
+                   timeout = server.socket_timeout,
+                   shutdown_timeout = server.shutdown_timeout,
+                   )
+        self.protocol = server.protocol_version
+        self.nodelay = server.nodelay
+        self.ssl_certificate = server.ssl_certificate
+        self.ssl_private_key = server.ssl_private_key
+

File cherrypy/lib/http.py

         return header_list
 
 
-from cherrypy.wsgiserver import MaxSizeExceeded
-
 
 class Host(object):
     """An internet address.