request 

Send to Kindle
home » snippets » python » tipfy » request



Notes

See werkzeug.wrappers.BaseRequest

Request in app.py

class Request(werkzeug.wrappers.Request):
    """Provides all environment variables for the current request: GET, POST,
    FILES, cookies and headers.
    """
    #: The WSGI app.
    app = None
    #: Exception caught by the WSGI app during dispatch().
    exception = None
    #: URL adapter.
    rule_adapter = None
    #: Matched :class:`tipfy.routing.Rule`.
    rule = None
    #: Keyword arguments from the matched rule.
    rule_args = None
    #: A dictionary for request variables.
    registry = None

    def __init__(self, *args, **kwargs):
        super(Request, self).__init__(*args, **kwargs)
        self.registry = {}

    @werkzeug.utils.cached_property
    def auth(self):
        """The auth store which provides access to the authenticated user and
        auth related functions.

        :returns:
            An auth store instance.
        """
        return self.app.auth_store_class(self)

    @werkzeug.utils.cached_property
    def json(self):
        """If the mimetype is `application/json` this will contain the
        parsed JSON data.

        This function is borrowed from `Flask`_.

        :returns:
            The decoded JSON request data.
        """
        if self.mimetype == 'application/json':
            from tipfy.json import json_decode
            return json_decode(self.data)

    @werkzeug.utils.cached_property
    def i18n(self):
        """The internationalization store which provides access to several
        translation and localization utilities.

        :returns:
            An i18n store instance.
        """
        return self.app.i18n_store_class(self)

    @werkzeug.utils.cached_property
    def session(self):
        """A session dictionary using the default session configuration.

        :returns:
            A dictionary-like object with the current session data.
        """
        return self.session_store.get_session()

    @werkzeug.utils.cached_property
    def session_store(self):
        """The session store, responsible for managing sessions and flashes.

        :returns:
            A session store instance.
        """
        return self.app.session_store_class(self)

    def _get_rule_adapter(self):
        from warnings import warn
        warn(DeprecationWarning("Request.url_adapter: this attribute "
          "is deprecated. Use Request.rule_adapter instead."))
        return self.rule_adapter

    def _set_rule_adapter(self, adapter):
        from warnings import warn
        warn(DeprecationWarning("Request.url_adapter: this attribute "
          "is deprecated. Use Request.rule_adapter instead."))
        self.rule_adapter = adapter

    # Old name
    url_adapter = property(_get_rule_adapter, _set_rule_adapter)

werkzeug.werkzeug.Request is

class werkzeug.wrappers.Request(environ,
                                populate_request=True,
                                shallow=False)

Full featured request object implementing the following mixins:

See werkzeug.wrappers.BaseRequest