summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris McDonough <chrism@plope.com>2011-08-19 08:27:20 -0400
committerChris McDonough <chrism@plope.com>2011-08-19 08:27:20 -0400
commitcfbbd6d1b6a0b3651b109f819e4b8d2bfe4f1575 (patch)
tree39245ebebcd665d6cfaac06bae8184ab46c6bc55
parenteb2a57640261c3f43fe8fc17a2d67e7e4bc3cef5 (diff)
downloadpyramid-cfbbd6d1b6a0b3651b109f819e4b8d2bfe4f1575.tar.gz
pyramid-cfbbd6d1b6a0b3651b109f819e4b8d2bfe4f1575.tar.bz2
pyramid-cfbbd6d1b6a0b3651b109f819e4b8d2bfe4f1575.zip
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
-rw-r--r--TODO.txt6
-rw-r--r--pyramid/config/__init__.py27
-rw-r--r--pyramid/config/rendering.py7
-rw-r--r--pyramid/config/tweens.py5
4 files changed, 20 insertions, 25 deletions
diff --git a/TODO.txt b/TODO.txt
index e06616acf..2cf0d5fbb 100644
--- a/TODO.txt
+++ b/TODO.txt
@@ -11,8 +11,6 @@ Should-Have
- 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 @@ Should-Have
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
@@ -44,8 +44,6 @@ Nice-to-Have
- Alias the stupid long default session factory name.
-- Fix indirect circular import between router and config.
-
- Add narrative docs for wsgiapp and wsgiapp2.
- Provide a ``has_view`` function.
diff --git a/pyramid/config/__init__.py b/pyramid/config/__init__.py
index 113ef4e06..91c351fa5 100644
--- a/pyramid/config/__init__.py
+++ b/pyramid/config/__init__.py
@@ -16,6 +16,7 @@ from zope.configuration.xmlconfig import registerCommonDirectives
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.httpexceptions import default_exceptionresponse_view
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 @@ class Configurator(
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 @@ class Configurator(
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 @@ class Configurator(
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,11 +330,11 @@ class Configurator(
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 @@ class Configurator(
: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))
diff --git a/pyramid/config/rendering.py b/pyramid/config/rendering.py
index ad75acb9f..3096b3d8e 100644
--- a/pyramid/config/rendering.py
+++ b/pyramid/config/rendering.py
@@ -42,13 +42,6 @@ class RenderingConfiguratorMixin(object):
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
diff --git a/pyramid/config/tweens.py b/pyramid/config/tweens.py
index c381a1101..4551c7fac 100644
--- a/pyramid/config/tweens.py
+++ b/pyramid/config/tweens.py
@@ -153,8 +153,3 @@ class TweensConfiguratorMixin(object):
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)
-