diff options
| author | Chris McDonough <chrism@agendaless.com> | 2009-10-30 18:56:58 +0000 |
|---|---|---|
| committer | Chris McDonough <chrism@agendaless.com> | 2009-10-30 18:56:58 +0000 |
| commit | 11644e705834ff65cb8963333855a1db6272ae1e (patch) | |
| tree | 6730225c3c81d52263f37ceac0876b11a57865ae /repoze/bfg/zcml.py | |
| parent | 1b2d8e7326cd1eaa95b3522d985e97642764c7c8 (diff) | |
| download | pyramid-11644e705834ff65cb8963333855a1db6272ae1e.tar.gz pyramid-11644e705834ff65cb8963333855a1db6272ae1e.tar.bz2 pyramid-11644e705834ff65cb8963333855a1db6272ae1e.zip | |
Features
--------
- In previous versions of BFG, the "root factory" (the ``get_root``
callable passed to ``make_app`` or a function pointed to by the
``factory`` attribute of a route) was called with a "bare" WSGI
environment. In this version, and going forward, it will be called
with a ``request`` object. The request object passed to the factory
implements dictionary-like methods in such a way that existing root
factory code which expects to be passed an environ will continue to
work.
Internal
--------
- The request implements dictionary-like methods that mutate and query
the WSGI environ. This is only for the purpose of backwards
compatibility with root factories which expect an ``environ`` rather
than a request.
- The ``repoze.bfg.request.create_route_request_factory`` function,
which returned a request factory was removed in favor of a
``repoze.bfg.request.route_request_interface`` function, which
returns an interface.
- 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).
- Reverse the order in which the router calls the request factory and
the root factory. The request factory is now called first; the
resulting request is passed to the root factory.
- The ``repoze.bfg.request.request_factory`` function has been
removed. Its functionality is no longer required.
- The "routes root factory" that wraps the default root factory when
there are routes mentioned in the configuration now attaches an
interface to the request via ``zope.interface.directlyProvides``.
This replaces logic in the (now-gone)
``repoze.bfg.request.request_factory`` function.
- The ``route`` and ``view`` ZCML directives now register an interface
as a named utility (retrieved from
``repoze.bfg.request.route_request_interface``) rather than a
request factory (the previous return value of the now-missing
``repoze.bfg.request.create_route_request_factory``.
Diffstat (limited to 'repoze/bfg/zcml.py')
| -rw-r--r-- | repoze/bfg/zcml.py | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/repoze/bfg/zcml.py b/repoze/bfg/zcml.py index c192fddfb..c39f06bb3 100644 --- a/repoze/bfg/zcml.py +++ b/repoze/bfg/zcml.py @@ -38,7 +38,7 @@ from repoze.bfg.authentication import AuthTktAuthenticationPolicy from repoze.bfg.authorization import ACLAuthorizationPolicy from repoze.bfg.configuration import zcml_configure from repoze.bfg.path import package_name -from repoze.bfg.request import create_route_request_factory +from repoze.bfg.request import route_request_iface from repoze.bfg.resource import PackageOverrides from repoze.bfg.resource import resource_spec from repoze.bfg.static import StaticRootFactory @@ -287,9 +287,8 @@ def view( else: request_type = queryUtility(IRouteRequest, name=route_name) if request_type is None: - factory = create_route_request_factory(route_name) - request_type = implementedBy(factory) - sm.registerUtility(factory, IRouteRequest, name=route_name) + request_type = route_request_iface(route_name) + sm.registerUtility(request_type, IRouteRequest, name=route_name) if isinstance(request_type, basestring): request_type = _context.resolve(request_type) @@ -634,11 +633,10 @@ def route(_context, name, path, view=None, view_for=None, request_type = None if request_type is None: - request_factory = queryUtility(IRouteRequest, name=name) - if request_factory is None: - request_factory = create_route_request_factory(name) - sm.registerUtility(request_factory, IRouteRequest, name=name) - request_type = implementedBy(request_factory) + request_type = queryUtility(IRouteRequest, name=name) + if request_type is None: + request_type = route_request_iface(name) + sm.registerUtility(request_type, IRouteRequest, name=name) if view: _view(_context, permission=permission, for_=for_, view=view, name='', |
