Added support for automagic OPTIONS

This commit is contained in:
Armin Ronacher 2010-07-12 23:04:24 +02:00
parent a532568680
commit 5e1b1030e8
7 changed files with 74 additions and 18 deletions

View file

@ -24,11 +24,12 @@ class Request(RequestBase):
:attr:`~flask.Flask.request_class` to your subclass.
"""
#: the endpoint that matched the request. This in combination with
#: :attr:`view_args` can be used to reconstruct the same or a
#: modified URL. If an exception happened when matching, this will
#: be `None`.
endpoint = None
#: the internal URL rule that matched the request. This can be
#: useful to inspect which methods are allowed for the URL from
#: a before/after handler (``request.url_rule.methods``) etc.
#:
#: .. versionadded:: 0.6
url_rule = None
#: a dict of view arguments that matched the request. If an exception
#: happened when matching, this will be `None`.
@ -40,6 +41,16 @@ class Request(RequestBase):
#: something similar.
routing_exception = None
@property
def endpoint(self):
"""The endpoint that matched the request. This in combination with
:attr:`view_args` can be used to reconstruct the same or a
modified URL. If an exception happened when matching, this will
be `None`.
"""
if self.url_rule is not None:
return self.url_rule.endpoint
@property
def module(self):
"""The name of the current module"""