Browse Source

Made it theoretically possible to hook into request matching

pull/262/head
Armin Ronacher 14 years ago
parent
commit
ab6bac111c
  1. 18
      flask/ctx.py

18
flask/ctx.py

@ -90,12 +90,7 @@ class RequestContext(object):
self.flashes = None
self.session = None
try:
url_rule, self.request.view_args = \
self.url_adapter.match(return_rule=True)
self.request.url_rule = url_rule
except HTTPException, e:
self.request.routing_exception = e
self.match_request()
# Support for deprecated functionality. This is doing away with
# Flask 1.0
@ -107,6 +102,17 @@ class RequestContext(object):
if bp is not None and blueprint_is_module(bp):
self.request._is_old_module = True
def match_request(self):
"""Can be overridden by a subclass to hook into the matching
of the request.
"""
try:
url_rule, self.request.view_args = \
self.url_adapter.match(return_rule=True)
self.request.url_rule = url_rule
except HTTPException, e:
self.request.routing_exception = e
def push(self):
"""Binds the request context to the current context."""
_request_ctx_stack.push(self)

Loading…
Cancel
Save