view MoinMoin/request/ @ 2938:bdd5df911941

remove request.reset_output
author Johannes Berg <johannes AT sipsolutions DOT net>
date Tue, 30 Oct 2007 22:39:42 +0100
parents b902f2397c68
children 806cf4814612
line wrap: on
line source

# -*- coding: iso-8859-1 -*-
    MoinMoin - WSGI Request Implementation for std. WSGI web servers.

    @copyright: 2001-2003 Juergen Hermann <>,
                2003-2006 MoinMoin:ThomasWaldmann
    @license: GNU GPL, see COPYING for details.
import cgi, StringIO

from MoinMoin.request import RequestBase

class Request(RequestBase):
    """ specialized on WSGI requests """
    def __init__(self, env):
            self.env = env
            self.hasContentType = False

            self.stdin = env['wsgi.input']
            self.stdout = StringIO.StringIO()

            # used by MoinMoin.server.wsgi:
            self.status = '200 OK'
            self.headers = []

            RequestBase.__init__(self, {})

        except Exception, err:

    def setup_args(self):
        # TODO: does this include query_string args for POST requests?
        # see also how CGI works now
        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=None):
        if n is None:

    def write(self, *data):

    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):

    def output(self):
        # called by MoinMoin.server.wsgi
        return self.stdout.getvalue()