Chris McDonough
2011-08-19 cfbbd6d1b6a0b3651b109f819e4b8d2bfe4f1575
add default renderers eagerly so they can be overridden, get rid of useless warning about ordering, comment about global_registries, no longer have a circular import between config and router
4 files modified
45 ■■■■■ changed files
TODO.txt 6 ●●●●● patch | view | raw | blame | history
pyramid/config/__init__.py 27 ●●●●● patch | view | raw | blame | history
pyramid/config/rendering.py 7 ●●●●● patch | view | raw | blame | history
pyramid/config/tweens.py 5 ●●●●● patch | view | raw | blame | history
TODO.txt
@@ -11,8 +11,6 @@
- Make it possible to use tween aliases in explicit tween config?  If not,
  the tween factories of all add-ons must be APIs.
- Merge Michael's route group work (maybe a 1.3 thing).
- Deprecate pyramid.security.view_execution_permitted (it only works for
  traversal).
@@ -29,6 +27,8 @@
Nice-to-Have
------------
- Merge Michael's route group work (maybe a 1.3 thing).
- Kill off ``bfg.routes`` envvars in router.
- Some sort of API for rendering a view callable object to a response from
@@ -43,8 +43,6 @@
  reimplement both).
- Alias the stupid long default session factory name.
- Fix indirect circular import between router and config.
- Add narrative docs for wsgiapp and wsgiapp2.
pyramid/config/__init__.py
@@ -16,6 +16,7 @@
from pyramid.interfaces import IExceptionResponse
from pyramid.interfaces import IDebugLogger
from pyramid.asset import resolve_asset_spec
from pyramid.authorization import ACLAuthorizationPolicy
from pyramid.events import ApplicationCreated
from pyramid.exceptions import ConfigurationError # bw compat
@@ -23,7 +24,7 @@
from pyramid.path import caller_package
from pyramid.path import package_of
from pyramid.registry import Registry
from pyramid.asset import resolve_asset_spec
from pyramid.router import Router
from pyramid.settings import aslist
from pyramid.threadlocal import manager
from pyramid.util import DottedNameResolver
@@ -217,7 +218,7 @@
                 root_factory=None,
                 authentication_policy=None,
                 authorization_policy=None,
                 renderers=DEFAULT_RENDERERS,
                 renderers=None,
                 debug_logger=None,
                 locale_negotiator=None,
                 request_factory=None,
@@ -259,7 +260,7 @@
    def setup_registry(self, settings=None, root_factory=None,
                       authentication_policy=None, authorization_policy=None,
                       renderers=DEFAULT_RENDERERS, debug_logger=None,
                       renderers=None, debug_logger=None,
                       locale_negotiator=None, request_factory=None,
                       renderer_globals_factory=None, default_permission=None,
                       session_factory=None, default_view_mapper=None,
@@ -295,6 +296,11 @@
                
        registry.registerUtility(debug_logger, IDebugLogger)
        if renderers is None:
            for name, renderer in DEFAULT_RENDERERS:
                self.add_renderer(name, renderer)
            renderers = []
        if exceptionresponse_view is not None:
            exceptionresponse_view = self.maybe_dotted(exceptionresponse_view)
            self.add_view(exceptionresponse_view, context=IExceptionResponse)
@@ -324,10 +330,10 @@
        if authorization_policy:
            self.set_authorization_policy(authorization_policy)
        self.set_root_factory(root_factory)
        for name, renderer in renderers:
            self.add_renderer(name, renderer)
        self.set_root_factory(root_factory)
        if locale_negotiator:
            self.set_locale_negotiator(locale_negotiator)
@@ -760,12 +766,15 @@
        :app:`Pyramid` WSGI application representing the committed
        configuration state."""
        self.commit()
        from pyramid.router import Router # avoid circdep
        app = Router(self.registry)
        # Allow tools like "paster pshell development.ini" to find the 'last'
        # registry configured.
        global_registries.add(self.registry)
        # We push the registry on to the stack here in case any code
        # that depends on the registry threadlocal APIs used in
        # listeners subscribed to the IApplicationCreated event.
        # Push the registry on to the stack in case any code that depends on
        # the registry threadlocal APIs used in listeners subscribed to the
        # IApplicationCreated event.
        self.manager.push({'registry':self.registry, 'request':None})
        try:
            self.registry.notify(ApplicationCreated(app))
pyramid/config/rendering.py
@@ -42,13 +42,6 @@
        The ``factory`` argument is Python reference to an
        implementation of a :term:`renderer` factory or a
        :term:`dotted Python name` to same.
        Note that this function must be called *before* any
        ``add_view`` invocation that names the renderer name as an
        argument.  As a result, it's usually a better idea to pass
        globally used renderers into the ``Configurator`` constructor
        in the sequence of renderers passed as ``renderer`` than it is
        to use this method.
        """
        factory = self.maybe_dotted(factory)
        # if name is None or the empty string, we're trying to register
pyramid/config/tweens.py
@@ -153,8 +153,3 @@
        if not explicit and alias is not None:
            self.action(('tween', alias, explicit))
    @action_method
    def add_request_handler(self, factory, name): # pragma: no cover
        # XXX bw compat for debugtoolbar
        return self._add_tween(factory, explicit=False)