view MoinMoin/request/ @ 647:bebe1a6eac56

add some missing imports in request/*
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Mon, 15 May 2006 19:23:27 +0200
parents 80d0ad85a2d8
children 882a8e99e0e8
line wrap: on
line source

# -*- coding: iso-8859-1 -*-
    MoinMoin - FastCGI Request Implementation for fastcgi and Apache
    (and maybe others).

    @copyright: 2001-2003 by Jürgen Hermann <>,
                2003-2006 MoinMoin:ThomasWaldmann
    @license: GNU GPL, see COPYING for details.
import sys, os
from MoinMoin import config
from MoinMoin.request import RequestBase

class Request(RequestBase):
    """ specialized on FastCGI requests """

    def __init__(self, fcgRequest, env, form, properties={}):
        """ Initializes variables from FastCGI environment and saves
            FastCGI request and form for further use.

            @param fcgRequest: the FastCGI request instance.
            @param env: environment passed by FastCGI.
            @param form: FieldStorage passed by FastCGI.
            self.fcgreq = fcgRequest
            self.fcgenv = env
            self.fcgform = form
            RequestBase.__init__(self, properties)

        except Exception, err:

    def _setup_args_from_cgi_form(self, form=None):
        """ Override to use FastCGI form """
        if form is None:
            form = self.fcgform
        return RequestBase._setup_args_from_cgi_form(self, form)

    def read(self, n=None):
        """ Read from input stream. """
        if n is None:

    def write(self, *data):
        """ Write to output stream. """

    def flush(self):
        """ Flush output stream. """

    def finish(self):
        """ Call finish method of FastCGI request to finish handling of this request. """

    # Headers ----------------------------------------------------------

    def http_headers(self, more_headers=[]):
        """ Send out HTTP headers. Possibly set a default content-type. """
        if getattr(self, 'sent_headers', None):
        self.sent_headers = 1
        have_ct = 0

        # send http headers
        for header in more_headers + getattr(self, 'user_headers', []):
            if type(header) is unicode:
                header = header.encode('ascii')
            if header.lower().startswith("content-type:"):
                # don't send content-type multiple times!
                if have_ct: continue
                have_ct = 1
            self.write("%s\r\n" % header)

        if not have_ct:
            self.write("Content-type: text/html;charset=%s\r\n" % config.charset)


        #from pprint import pformat