view MoinMoin/web/ @ 4179:00a4837da41a

Consolidate Request and Response into single object
author Florian Krupicka <>
date Thu, 19 Jun 2008 17:37:53 +0200
parents 917970e17b73
children 42660b499488
line wrap: on
line source
# -*- coding: iso-8859-1 -*-
    MoinMoin - New slimmed down WSGI Request.

    @copyright: 2008-2008 MoinMoin:FlorianKrupicka
    @license: GNU GPL, see COPYING for details.

import re

from werkzeug.wrappers import Request as WerkzeugRequest
from werkzeug.wrappers import Response as WerkzeugResponse
from werkzeug.utils import EnvironHeaders, cached_property

from MoinMoin import config

from MoinMoin import log
logging = log.getLogger(__name__)

class Request(WerkzeugRequest, WerkzeugResponse):
    """ A full featured Request/Response object.

    To better distinguish incoming and outgoing data/headers,
    incoming versions are prefixed with 'in_' in contrast to
    original Werkzeug implementation.
    charset = config.charset
    encoding_errors = 'replace'
    default_mimetype = 'text/html'

    def __init__(self, environ, populate_request=True, shallow=False,
                 response=None, status=None, headers=None, mimetype=None,
        WerkzeugRequest.__init__(self, environ, populate_request, shallow)
        WerkzeugResponse.__init__(self, response, status, headers,
                                  mimetype, content_type)

    data =
    stream =

    def in_headers(self):
        return EnvironHeaders(self.environ)
    in_headers = cached_property(in_headers, doc=WerkzeugRequest.headers.__doc__)

    def in_stream(self):
        if self._data_stream is None:
        return self._data_stream
    in_stream = property(in_stream,

    def in_data(self):
    in_data = cached_property(in_data,