view MoinMoin/request/ @ 4510:6180f7b85a45

Modernized theme: make nonexistent links gray also when the yare already visited
author Radomir Dopieralski <>
date Sat, 24 Jan 2009 21:49:44 +0100
parents fee546fba271
line wrap: on
line source
# -*- coding: iso-8859-1 -*-
    MoinMoin - FastCGI Request Implementation for fastcgi and Apache
    (and maybe others).

    @copyright: 2001-2003 Juergen Hermann <>,
                2003-2006 MoinMoin:ThomasWaldmann
    @license: GNU GPL, see COPYING for details.
from MoinMoin import log
logging = log.getLogger(__name__)

from MoinMoin.request import RequestBase, RemoteClosedConnection

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):
        """ Override to use FastCGI form """
        # thfcgi used keep_blank_values=1 internally for fcgform
        return RequestBase._setup_args_from_cgi_form(self, self.fcgform)

    def read(self, n):
        """ Read from input stream. """
        if n is None:
            logging.warning("calling might block")

    def write(self, *data):
        """ Write to output stream. """
        data = self.encode(data)
        except Exception:
            raise RemoteClosedConnection()

    def send_file(self, fileobj, bufsize=8192, do_flush=True):
        # as thfcgi buffers everything we write until we do a flush, we use
        # do_flush=True as default here (otherwise the sending of big file
        # attachments would consume lots of memory)
        return RequestBase.send_file(self, fileobj, bufsize, do_flush)

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

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

    def _emit_http_headers(self, headers):
        """ private method to send out preprocessed list of HTTP headers """
        for header in headers:
            self.write("%s\r\n" % header)