diff options
| author | Chris McDonough <chrism@agendaless.com> | 2010-02-02 03:18:21 +0000 |
|---|---|---|
| committer | Chris McDonough <chrism@agendaless.com> | 2010-02-02 03:18:21 +0000 |
| commit | 362061b24ce3f5d187a4a3a14f566c1653bccfb9 (patch) | |
| tree | ec98c0be57e836b050f7b9a42a7e9377d7a2225f | |
| parent | bd363b8e0028f13819d833f02358f617e09a5d8a (diff) | |
| download | pyramid-362061b24ce3f5d187a4a3a14f566c1653bccfb9.tar.gz pyramid-362061b24ce3f5d187a4a3a14f566c1653bccfb9.tar.bz2 pyramid-362061b24ce3f5d187a4a3a14f566c1653bccfb9.zip | |
- Remove ``view_header``, ``view_accept``, ``view_xhr``,
``view_path_info``, ``view_request_method``, ``view_request_param``,
and ``view_containment`` predicate arguments from the
``Configurator.add_route`` argument list. These arguments were
speculative. If you need the features exposed by these arguments,
add a view associated with a route using the ``route_name`` argument
to the ``add_view`` method instead.
- Remove ``view_header``, ``view_accept``, ``view_xhr``,
``view_path_info``, ``view_request_method``, ``view_request_param``,
and ``view_containment`` predicate arguments from the ``route`` ZCML
directive attribute set. These attributes were speculative. If you
need the features exposed by these attributes, add a view associated
with a route using the ``route_name`` attribute of the ``view`` ZCML
directive instead.
| -rw-r--r-- | CHANGES.txt | 16 | ||||
| -rw-r--r-- | docs/narr/urldispatch.rst | 21 | ||||
| -rw-r--r-- | docs/zcml/route.rst | 25 | ||||
| -rw-r--r-- | repoze/bfg/configuration.py | 62 | ||||
| -rw-r--r-- | repoze/bfg/tests/test_configuration.py | 83 | ||||
| -rw-r--r-- | repoze/bfg/tests/test_zcml.py | 12 | ||||
| -rw-r--r-- | repoze/bfg/zcml.py | 52 |
7 files changed, 62 insertions, 209 deletions
diff --git a/CHANGES.txt b/CHANGES.txt index 85a0245ec..52d158138 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,6 +1,22 @@ Next release ============ +- Remove ``view_header``, ``view_accept``, ``view_xhr``, + ``view_path_info``, ``view_request_method``, ``view_request_param``, + and ``view_containment`` predicate arguments from the + ``Configurator.add_route`` argument list. These arguments were + speculative. If you need the features exposed by these arguments, + add a view associated with a route using the ``route_name`` argument + to the ``add_view`` method instead. + +- Remove ``view_header``, ``view_accept``, ``view_xhr``, + ``view_path_info``, ``view_request_method``, ``view_request_param``, + and ``view_containment`` predicate arguments from the ``route`` ZCML + directive attribute set. These attributes were speculative. If you + need the features exposed by these attributes, add a view associated + with a route using the ``route_name`` attribute of the ``view`` ZCML + directive instead. + - Remove dependency on ``sourcecodegen`` (not depended upon by Chameleon 1.1.1+). diff --git a/docs/narr/urldispatch.rst b/docs/narr/urldispatch.rst index 495b05a14..d766eba09 100644 --- a/docs/narr/urldispatch.rst +++ b/docs/narr/urldispatch.rst @@ -550,27 +550,6 @@ information. This argument can also be spelled as ``renderer``. -``view_request_type`` - A reference to an :term:`interface` representing a :term:`request - type`. If this argument is not specified, any request type will be - considered a match for the view associated with this route. - - If the ``view`` argument is not provided, this argument has - no effect. - - This argument can also be spelled as ``request_type``. - -``view_containment`` - This value should be a reference to a Python class or - :term:`interface` that a parent object in the :term:`lineage` must - provide in order for the view related to this route to be found and - called. Your models must be 'location-aware' to use this feature. - See :ref:`location_aware` for more information about - location-awareness. - - If the ``view`` argument is not provided, this argument has no - effect. - ``view_attr`` The view machinery defaults to using the ``__call__`` method of the view callable (or the function itself, if the view callable is a diff --git a/docs/zcml/route.rst b/docs/zcml/route.rst index 169252d77..8bee3c14f 100644 --- a/docs/zcml/route.rst +++ b/docs/zcml/route.rst @@ -162,31 +162,6 @@ Attributes .. note:: This feature is new as of :mod:`repoze.bfg` 1.1. -``view_request_type`` - A :term:`dotted Python name` to an interface representing a - :term:`request type`. If this argument is not specified, any - request type will be considered a match for the view associated with - this route. - - If the ``view`` attribute is not provided, this attribute has no - effect. - - This attribute can also be spelled as ``request_type``. - -``view_containment`` - This value should be a :term:`dotted Python name` string - representing the class that a graph traversal parent object of the - :term:`context` must be an instance of (or :term:`interface` that a - parent object must provide) in order for this view to be found and - called. Your models must be "location-aware" to use this feature. - See :ref:`location_aware` for more information about - location-awareness. - - If the ``view`` attribute is not provided, this attribute has no - effect. - - .. note:: This feature is new as of :mod:`repoze.bfg` 1.1. - ``view_attr`` The view machinery defaults to using the ``__call__`` method of the view callable (or the function itself, if the view callable is a diff --git a/repoze/bfg/configuration.py b/repoze/bfg/configuration.py index 2fff1054c..8a254bdec 100644 --- a/repoze/bfg/configuration.py +++ b/repoze/bfg/configuration.py @@ -800,17 +800,26 @@ class Configurator(object): self.registry.registerAdapter(multiview, (request_iface, context), IMultiView, name, info=_info) - def add_route(self, name, path, view=None, view_for=None, - permission=None, factory=None, for_=None, - header=None, xhr=False, accept=None, path_info=None, - request_method=None, request_param=None, + def add_route(self, + name, + path, + view=None, + view_for=None, + permission=None, + factory=None, + for_=None, + header=None, + xhr=False, + accept=None, + path_info=None, + request_method=None, + request_param=None, custom_predicates=(), - view_permission=None, view_request_method=None, - view_request_param=None, - view_containment=None, view_attr=None, - renderer=None, view_renderer=None, view_header=None, - view_accept=None, view_xhr=False, - view_path_info=None, view_context=None, + view_permission=None, + renderer=None, + view_renderer=None, + view_context=None, + view_attr=None, use_global_views=False, _info=u''): """ Add a :term:`route configuration` to the current @@ -992,31 +1001,6 @@ class Configurator(object): This argument can also be spelled as ``renderer``. - view_request_type - - A reference to an :term:`interface` representing a - :term:`request type`. If this argument is not specified, - any request type will be considered a match for the view - associated with this route. - - If the ``view`` argument is not provided, this argument has - no effect. - - This argument can also be spelled as ``request_type``. - - view_containment - - This value should be a reference to a Python class or - :term:`interface` that a parent object in the - :term:`lineage` must provide in order for the view related - to this route to be found and called. Your models must be - 'location-aware' to use this feature. See - :ref:`location_aware` for more information about - location-awareness. - - If the ``view`` argument is not provided, this argument has no - effect. - view_attr The view machinery defaults to using the ``__call__`` method @@ -1079,15 +1063,7 @@ class Configurator(object): view=view, name='', route_name=name, - request_method=view_request_method, - request_param=view_request_param, - containment=view_containment, - attr=view_attr, renderer=view_renderer, - header=view_header, - accept=view_accept, - xhr=view_xhr, - path_info=view_path_info, _info=_info, ) diff --git a/repoze/bfg/tests/test_configuration.py b/repoze/bfg/tests/test_configuration.py index 2e4ba3a18..78e1949e4 100644 --- a/repoze/bfg/tests/test_configuration.py +++ b/repoze/bfg/tests/test_configuration.py @@ -1186,89 +1186,6 @@ class ConfiguratorTests(unittest.TestCase): wrapper = self._getViewCallable(config, IOther, request_type) self.assertEqual(wrapper, None) - def test_add_route_with_view_request_method(self): - config = self._makeOne() - view = lambda *arg: 'OK' - config.add_route('name', 'path', view=view, view_request_method='GET') - request_type = self._getRouteRequestIface(config, 'name') - wrapper = self._getViewCallable(config, None, request_type) - self._assertRoute(config, 'name', 'path') - request = self._makeRequest(config) - request.method = 'GET' - self.assertEqual(wrapper(None, request), 'OK') - request = self._makeRequest(config) - request.method = 'POST' - self._assertNotFound(wrapper, None, request) - - def test_add_route_with_view_header(self): - config = self._makeOne() - view = lambda *arg: 'OK' - config.add_route('name', 'path', view=view, view_header='Host') - request_type = self._getRouteRequestIface(config, 'name') - wrapper = self._getViewCallable(config, None, request_type) - self._assertRoute(config, 'name', 'path') - request = self._makeRequest(config) - request.headers = {'Host':'abc'} - self.assertEqual(wrapper(None, request), 'OK') - request = self._makeRequest(config) - request.headers = {} - self._assertNotFound(wrapper, None, request) - - def test_add_route_with_view_xhr(self): - config = self._makeOne() - view = lambda *arg: 'OK' - config.add_route('name', 'path', view=view, view_xhr=True) - request_type = self._getRouteRequestIface(config, 'name') - wrapper = self._getViewCallable(config, None, request_type) - self._assertRoute(config, 'name', 'path') - request = self._makeRequest(config) - request.is_xhr = True - self.assertEqual(wrapper(None, request), 'OK') - request = self._makeRequest(config) - request.is_xhr = False - self._assertNotFound(wrapper, None, request) - - def test_add_route_with_view_path_info(self): - config = self._makeOne() - view = lambda *arg: 'OK' - config.add_route('name', 'path', view=view, view_path_info='/foo') - request_type = self._getRouteRequestIface(config, 'name') - wrapper = self._getViewCallable(config, None, request_type) - self._assertRoute(config, 'name', 'path') - request = self._makeRequest(config) - request.path_info = '/foo' - self.assertEqual(wrapper(None, request), 'OK') - request = self._makeRequest(config) - request.path_info = '/' - self._assertNotFound(wrapper, None, request) - - def test_add_route_with_view_accept(self): - config = self._makeOne() - view = lambda *arg: 'OK' - config.add_route('name', 'path', view=view, view_accept='text/xml') - request_type = self._getRouteRequestIface(config, 'name') - wrapper = self._getViewCallable(config, None, request_type) - self._assertRoute(config, 'name', 'path') - request = self._makeRequest(config) - request.accept = ['text/xml'] - self.assertEqual(wrapper(None, request), 'OK') - request = self._makeRequest(config) - request.accept = ['text/html'] - self._assertNotFound(wrapper, None, request) - - def test_add_route_with_view_containment(self): - from zope.interface import directlyProvides - config = self._makeOne() - view = lambda *arg: 'OK' - config.add_route('name', 'path', view=view, view_containment=IDummy) - request_type = self._getRouteRequestIface(config, 'name') - wrapper = self._getViewCallable(config, None, request_type) - self._assertRoute(config, 'name', 'path') - context = DummyContext() - directlyProvides(context, IDummy) - self.assertEqual(wrapper(context, None), 'OK') - self._assertNotFound(wrapper, None, None) - def test_add_route_with_view_renderer(self): config = self._makeOne() self._registerRenderer(config) diff --git a/repoze/bfg/tests/test_zcml.py b/repoze/bfg/tests/test_zcml.py index 2d9d59b64..1784a6aa8 100644 --- a/repoze/bfg/tests/test_zcml.py +++ b/repoze/bfg/tests/test_zcml.py @@ -521,8 +521,7 @@ class TestRouteDirective(unittest.TestCase): reg = get_current_registry() request_type = reg.getUtility(IRouteRequest, 'name') view_discriminator = view_action['discriminator'] - discrim = ('view', None, '', None, IView, None, None, None, - 'name', None, False, None, None, None) + discrim = ('view', None, '', None, IView, 'name', None) self.assertEqual(view_discriminator, discrim) wrapped = reg.adapters.lookup((request_type, Interface), IView, name='') self.failUnless(wrapped) @@ -548,8 +547,7 @@ class TestRouteDirective(unittest.TestCase): reg = get_current_registry() request_type = reg.getUtility(IRouteRequest, 'name') view_discriminator = view_action['discriminator'] - discrim = ('view', IDummy, '', None, IView, None, None, None, - 'name', None, False, None, None, None) + discrim = ('view', IDummy, '', None, IView, 'name', None) self.assertEqual(view_discriminator, discrim) wrapped = reg.adapters.lookup((request_type, IDummy), IView, name='') self.failUnless(wrapped) @@ -578,8 +576,7 @@ class TestRouteDirective(unittest.TestCase): reg = get_current_registry() request_type = reg.getUtility(IRouteRequest, 'name') view_discriminator = view_action['discriminator'] - discrim = ('view', IDummy, '', None, IView, None, None, None, - 'name', None, False, None, None, None) + discrim = ('view', IDummy, '', None, IView, 'name', None) self.assertEqual(view_discriminator, discrim) wrapped = reg.adapters.lookup((request_type, IDummy), IView, name='') self.failUnless(wrapped) @@ -615,8 +612,7 @@ class TestRouteDirective(unittest.TestCase): view_action = actions[1] request_type = reg.getUtility(IRouteRequest, 'name') view_discriminator = view_action['discriminator'] - discrim = ('view', None, '', None, IView, None, None, None, - 'name', None, False, None, None, None) + discrim = ('view', None, '', None, IView, 'name', None) self.assertEqual(view_discriminator, discrim) wrapped = reg.adapters.lookup((request_type, Interface), IView, name='') self.failUnless(wrapped) diff --git a/repoze/bfg/zcml.py b/repoze/bfg/zcml.py index 17bfbb66f..297a59434 100644 --- a/repoze/bfg/zcml.py +++ b/repoze/bfg/zcml.py @@ -237,15 +237,7 @@ class IRouteDirective(Interface): # alias for view_renderer renderer = TextLine(title=u'renderer', required=False) - view_request_method = TextLine(title=u'view_request_method', required=False) - view_containment = GlobalObject( - title = u'Dotted name of a containment class or interface', - required=False) view_attr = TextLine(title=u'view_attr', required=False) - view_header = TextLine(title=u'view_header', required=False) - view_accept = TextLine(title=u'view_accept', required=False) - view_xhr = Bool(title=u'view_xhr', required=False) - view_path_info = TextLine(title=u'view_path_info', required=False) request_method = TextLine(title=u'request_method', required=False) request_param = TextLine(title=u'request_param', required=False) @@ -262,20 +254,32 @@ class IRouteDirective(Interface): ) use_global_views = Bool(title=u'use_global_views', required=False) -def route(_context, name, path, view=None, view_for=None, - permission=None, factory=None, for_=None, - header=None, xhr=False, accept=None, path_info=None, - request_method=None, request_param=None, custom_predicates=(), - view_permission=None, view_request_method=None, - view_request_param=None, view_containment=None, view_attr=None, - renderer=None, view_renderer=None, view_header=None, - view_accept=None, view_xhr=False, - view_path_info=None, view_context=None, +def route(_context, + name, + path, + view=None, + view_for=None, + permission=None, + factory=None, + for_=None, + header=None, + xhr=False, + accept=None, + path_info=None, + request_method=None, + request_param=None, + custom_predicates=(), + view_permission=None, + view_attr=None, + renderer=None, + view_renderer=None, + view_context=None, use_global_views=False): """ Handle ``route`` ZCML directives """ # the strange ordering of the request kw args above is for b/w # compatibility purposes. + # these are route predicates; if they do not match, the next route # in the routelist will be tried reg = get_current_registry() @@ -304,15 +308,8 @@ def route(_context, name, path, view=None, view_for=None, view=view, view_context=view_context, view_permission=view_permission, - view_request_method=view_request_method, - view_request_param=view_request_param, - view_containment=view_containment, - view_attr=view_attr, view_renderer=view_renderer, - view_header=view_header, - view_accept=view_accept, - view_xhr=view_xhr, - view_path_info=view_path_info, + view_attr=view_attr, use_global_views=use_global_views, _info=_context.info ) @@ -334,10 +331,7 @@ def route(_context, name, path, view=None, view_for=None, reg.registerUtility(request_iface, IRouteRequest, name=name) _context.action( discriminator = ( - 'view', view_context, '', None, IView, - view_containment, view_request_param, view_request_method, - name, view_attr, view_xhr, view_accept, view_header, - view_path_info), + 'view', view_context, '', None, IView, name, view_attr), ) class ISystemViewDirective(Interface): |
