changeset 4272:0b5f28e79da7

Point moin.wsgi to the new real application
author Florian Krupicka <florian.krupicka@googlemail.com>
date Wed, 06 Aug 2008 23:53:17 +0200
parents 793bf51b6c76
children 40dd44a3fcff
files MoinMoin/request/request_wsgi.py MoinMoin/server/server_wsgi.py wiki/server/moin.wsgi
diffstat 3 files changed, 1 insertions(+), 129 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/request/request_wsgi.py	Wed Aug 06 23:27:13 2008 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,80 +0,0 @@
-# -*- coding: iso-8859-1 -*-
-"""
-    MoinMoin - WSGI Request Implementation for std. WSGI web servers.
-
-    @copyright: 2001-2003 Juergen Hermann <jh@web.de>,
-                2003-2006 MoinMoin:ThomasWaldmann
-    @license: GNU GPL, see COPYING for details.
-"""
-import cgi, StringIO
-
-from MoinMoin import log
-logging = log.getLogger(__name__)
-
-from MoinMoin.request import RequestBase, RemoteClosedConnection
-
-class Request(RequestBase):
-    """ specialized on WSGI requests """
-    def __init__(self, env):
-        try:
-            self.env = env
-            self.hasContentType = False
-
-            self.stdin = env['wsgi.input']
-            self.stdout = StringIO.StringIO()
-
-            # used by MoinMoin.server.server_wsgi:
-            self.status = '200 OK'
-            self.headers = []
-
-            # used by send_file()
-            self._send_file = None
-            self._send_bufsize = None
-
-            self._setup_vars_from_std_env(env)
-            RequestBase.__init__(self, {})
-
-        except Exception, err:
-            self.fail(err)
-
-    def _setup_args_from_cgi_form(self):
-        """ Override to create cgi form """
-        form = cgi.FieldStorage(fp=self.stdin, environ=self.env, keep_blank_values=1)
-        return RequestBase._setup_args_from_cgi_form(self, form)
-
-    def read(self, n):
-        if n is None:
-            logging.warning("calling request.read(None) might block")
-            return self.stdin.read()
-        else:
-            return self.stdin.read(n)
-
-    def send_file(self, fileobj, bufsize=8192, do_flush=None):
-        # For now, we just remember fileobj and bufsize for sending it later:
-        self._send_file = fileobj
-        self._send_bufsize = bufsize
-
-    def write(self, *data):
-        data = self.encode(data)
-        try:
-            self.stdout.write(data)
-        except Exception:
-            raise RemoteClosedConnection()
-
-    def _emit_http_headers(self, headers):
-        """ private method to send out preprocessed list of HTTP headers """
-        st_header, other_headers = headers[0], headers[1:]
-        self.status = st_header.split(':', 1)[1].lstrip()
-        for header in other_headers:
-            key, value = header.split(':', 1)
-            value = value.lstrip()
-            self.headers.append((key, value))
-
-    def flush(self):
-        pass
-
-    def output(self):
-        # called by MoinMoin.server.server_wsgi
-        return self.stdout.getvalue()
-
-
--- a/MoinMoin/server/server_wsgi.py	Wed Aug 06 23:27:13 2008 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,39 +0,0 @@
-"""
-    MoinMoin - WSGI application
-
-    Minimal code for using this:
-
-    from MoinMoin.server.server_wsgi import WsgiConfig, moinmoinApp
-
-    class Config(WsgiConfig):
-        pass
-
-    config = Config() # you MUST create an instance
-    # use moinmoinApp here with your WSGI server / gateway
-
-    @copyright: 2005 Anakim Border <akborder@gmail.com>,
-                2007 MoinMoin:ThomasWaldmann
-    @license: GNU GPL, see COPYING for details.
-"""
-
-from MoinMoin.server import Config
-from MoinMoin.request import request_wsgi
-
-class WsgiConfig(Config):
-    """ WSGI default config """
-    pass
-
-
-def moinmoinApp(environ, start_response):
-    request = request_wsgi.Request(environ)
-    request.run()
-    start_response(request.status, request.headers)
-    if request._send_file is not None:
-        # moin wants to send a file (e.g. AttachFile.do_get)
-        def simple_wrapper(fileobj, bufsize):
-            return iter(lambda: fileobj.read(bufsize), '')
-        file_wrapper = environ.get('wsgi.file_wrapper', simple_wrapper)
-        return file_wrapper(request._send_file, request._send_bufsize)
-    else:
-        return [request.output()] # don't we have a filelike there also!?
-
--- a/wiki/server/moin.wsgi	Wed Aug 06 23:27:13 2008 +0200
+++ b/wiki/server/moin.wsgi	Wed Aug 06 23:53:17 2008 +0200
@@ -46,13 +46,4 @@
 # Debug mode - show detailed error reports
 #os.environ['MOIN_DEBUG'] = '1'
 
-
-from MoinMoin.server.server_wsgi import WsgiConfig, moinmoinApp
-
-class Config(WsgiConfig):
-    pass
-
-config = Config()
-
-application = moinmoinApp
-
+from MoinMoin.wsgiapp import application