summaryrefslogtreecommitdiff
path: root/repoze/bfg/router.py
diff options
context:
space:
mode:
authorChris McDonough <chrism@agendaless.com>2009-10-29 23:07:48 +0000
committerChris McDonough <chrism@agendaless.com>2009-10-29 23:07:48 +0000
commit1646770c4eee27f37e53dcb50f8a271d5c278abf (patch)
tree9021b72a986148b17b4eb74c66ccacbe00be2b55 /repoze/bfg/router.py
parentd8c776df0ff6a194be696c95d921caf2084194c6 (diff)
downloadpyramid-1646770c4eee27f37e53dcb50f8a271d5c278abf.tar.gz
pyramid-1646770c4eee27f37e53dcb50f8a271d5c278abf.tar.bz2
pyramid-1646770c4eee27f37e53dcb50f8a271d5c278abf.zip
- The ``repoze.bfg.request.Request`` class, which is a subclass of
``webob.Request`` now defines its own ``__setattr__``, ``__getattr__`` and ``__delattr__`` methods, which override the default WebOb behavior. The default WebOb behavior stores attributes of the request in ``self.environ['webob.adhoc_attrs']``, and retrieves them from that dictionary during a ``__getattr__``. This behavior was undesirable for speed and "expectation" reasons. Now attributes of the ``request`` are stored in ``request.__dict__`` (as you otherwise might expect from an object that did not override these methods). - The router no longer calls ``repoze.bfg.traversal._traverse`` and does its work "inline" (speed).
Diffstat (limited to 'repoze/bfg/router.py')
-rw-r--r--repoze/bfg/router.py14
1 files changed, 7 insertions, 7 deletions
diff --git a/repoze/bfg/router.py b/repoze/bfg/router.py
index abb2c6f0a..5f5214c10 100644
--- a/repoze/bfg/router.py
+++ b/repoze/bfg/router.py
@@ -9,6 +9,7 @@ from repoze.bfg.interfaces import INotFoundView
from repoze.bfg.interfaces import IRootFactory
from repoze.bfg.interfaces import IRouter
from repoze.bfg.interfaces import ISettings
+from repoze.bfg.interfaces import ITraverser
from repoze.bfg.interfaces import IView
from repoze.bfg.configuration import make_registry
@@ -20,7 +21,7 @@ from repoze.bfg.exceptions import Forbidden
from repoze.bfg.exceptions import NotFound
from repoze.bfg.request import request_factory
from repoze.bfg.threadlocal import manager
-from repoze.bfg.traversal import _traverse
+from repoze.bfg.traversal import ModelGraphTraverser
from repoze.bfg.view import default_forbidden_view
from repoze.bfg.view import default_notfound_view
@@ -62,17 +63,16 @@ class Router(object):
root = self.root_factory(environ)
request = request_factory(environ)
- # webob.Request's __setattr__ (as of 0.9.5 and lower) is a
- # bottleneck; since we're sure we're using a
- # webob.Request, we can go around its back and set stuff
- # into the environ directly
- attrs = environ.setdefault('webob.adhoc_attrs', {})
+ attrs = request.__dict__
attrs['registry'] = registry
attrs['root'] = root
threadlocals['request'] = request
registry.has_listeners and registry.notify(NewRequest(request))
- tdict = _traverse(root, environ)
+ traverser = registry.queryAdapter(root, ITraverser)
+ if traverser is None:
+ traverser = ModelGraphTraverser(root)
+ tdict = traverser(environ)
context, view_name, subpath, traversed, vroot, vroot_path = (
tdict['context'], tdict['view_name'], tdict['subpath'],
tdict['traversed'], tdict['virtual_root'],