summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBlaise Laflamme <blaise@laflamme.org>2010-11-04 15:01:20 -0400
committerBlaise Laflamme <blaise@laflamme.org>2010-11-04 15:01:20 -0400
commit5a48062afc72c4dc899bf9ec032ce2bc1d249448 (patch)
treed4826f3fe62b8be6197d414342bb43de0fbcaa79
parentc6198aa3a05716e7a98d837600a48994d6d7b61a (diff)
parentea979e868855d935b53a31bbf64e8d27a67ce63f (diff)
downloadpyramid-5a48062afc72c4dc899bf9ec032ce2bc1d249448.tar.gz
pyramid-5a48062afc72c4dc899bf9ec032ce2bc1d249448.tar.bz2
pyramid-5a48062afc72c4dc899bf9ec032ce2bc1d249448.zip
Merge branch 'master' of git://github.com/Pylons/pyramid
-rw-r--r--CHANGES.txt20
-rw-r--r--TODO.txt4
-rw-r--r--docs/zcml/view.rst6
-rw-r--r--pyramid/configuration.py5
-rw-r--r--pyramid/tests/test_configuration.py13
-rw-r--r--pyramid/tests/test_zcml.py62
-rw-r--r--pyramid/zcml.py20
7 files changed, 21 insertions, 109 deletions
diff --git a/CHANGES.txt b/CHANGES.txt
index 266353b6e..aa2b0bcbd 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -76,6 +76,12 @@ Features (delta from BFG 1.3.X)
``webob.Response`` (old code need not change to use this facade, it's
existence is mostly for vanity and documentation-generation purposes).
+- All preexisting paster templates (except ``zodb``) now use "imperative"
+ configuration (``starter``, ``routesalchemy``, ``alchemy``).
+
+- A new paster template named ``pyramid_starter_zcml`` exists, which uses
+ declarative configuration.
+
Documentation (delta from BFG 1.3)
-----------------------------------
@@ -169,9 +175,11 @@ Backwards Incompatibilities (with BFG 1.3.X)
``pyramid.authentication.AuthTktAuthenticationPolicy`` constructor now
defaults to ``auth_tkt`` (it used to default to ``repoze.bfg.auth_tkt``).
-- All preexisting paster templates (except ``zodb``) now use "imperative"
- configuration (``starter``, ``routesalchemy``, ``alchemy``).
-
-- A new paster template named ``pyramid_starter_zcml`` exists, which uses
- declarative configuration.
-
+- The ``request_type`` argument to the ``view`` ZCML directive, the
+ ``pyramid.configuration.Configurator.add_view`` method, or the
+ ``pyramid.view.view_config`` decorator (nee ``bfg_view``) is no longer
+ permitted to be one of the strings ``GET``, ``HEAD``, ``PUT``, ``POST`` or
+ ``DELETE``, and now must always be an interface. Accepting the
+ method-strings as ``request_type`` was a backwards compatibility strategy
+ servicing repoze.bfg 1.0 applications. Use the ``request_method``
+ parameter instead to specify that a view a string request-method predicate.
diff --git a/TODO.txt b/TODO.txt
index e66240bbb..ad944fb88 100644
--- a/TODO.txt
+++ b/TODO.txt
@@ -91,4 +91,6 @@
- repoze.bfg.viewgroup in CMF tutorial
-- templates in tutorials.
+- Update templates in tutorials.
+
+- Move static dir from pkg/templates/ to /pkg/ in pyramid_* paster templates.
diff --git a/docs/zcml/view.rst b/docs/zcml/view.rst
index 392e84430..8117e8ea6 100644
--- a/docs/zcml/view.rst
+++ b/docs/zcml/view.rst
@@ -132,11 +132,7 @@ Predicate Attributes
representing the :term:`interface` that the :term:`request` must
have in order for this view to be found and called. The presence of
this attribute is largely for backwards compatibility with
- older iterations of this framework. This value
- may be an HTTP ``REQUEST_METHOD`` string, e.g. ('GET', 'HEAD',
- 'PUT', 'POST', or 'DELETE'). Passing request method strings as a
- ``request_type`` is deprecated. Use the ``request_method``
- attribute instead for maximum forward compatibility.
+ older iterations of this framework.
``request_method``
This value can either be one of the strings 'GET', 'POST', 'PUT',
diff --git a/pyramid/configuration.py b/pyramid/configuration.py
index bf5dcce2d..936ed7b15 100644
--- a/pyramid/configuration.py
+++ b/pyramid/configuration.py
@@ -1030,11 +1030,6 @@ class Configurator(object):
raise ConfigurationError('"view" was not specified and '
'no "renderer" specified')
- if request_type in ('GET', 'HEAD', 'PUT', 'POST', 'DELETE'):
- # b/w compat for 1.0
- request_method = request_type
- request_type = None
-
if request_type is not None:
request_type = self.maybe_dotted(request_type)
if not IInterface.providedBy(request_type):
diff --git a/pyramid/tests/test_configuration.py b/pyramid/tests/test_configuration.py
index 482bf323d..f41c86840 100644
--- a/pyramid/tests/test_configuration.py
+++ b/pyramid/tests/test_configuration.py
@@ -640,19 +640,6 @@ class ConfiguratorTests(unittest.TestCase):
self.assertRaises(ConfigurationError, config.add_view, view, '', None,
None, True, True)
- def test_add_view_with_request_type_methodname_string(self):
- view = lambda *arg: 'OK'
- config = self._makeOne()
- config.add_view(view=view, request_type='GET')
- wrapper = self._getViewCallable(config)
- request = DummyRequest()
- request.method = 'POST'
- self._assertNotFound(wrapper, None, request)
- request = DummyRequest()
- request.method = 'GET'
- result = wrapper(None, request)
- self.assertEqual(result, 'OK')
-
def test_add_view_with_request_type(self):
from zope.interface import directlyProvides
from pyramid.interfaces import IRequest
diff --git a/pyramid/tests/test_zcml.py b/pyramid/tests/test_zcml.py
index 5de9229cf..8a4bca258 100644
--- a/pyramid/tests/test_zcml.py
+++ b/pyramid/tests/test_zcml.py
@@ -20,68 +20,6 @@ class TestViewDirective(unittest.TestCase):
from pyramid.zcml import view
return view(*arg, **kw)
- def test_request_type_ashttpmethod(self):
- from pyramid.threadlocal import get_current_registry
- from pyramid.interfaces import IView
- from pyramid.interfaces import IViewClassifier
- from pyramid.interfaces import IRequest
- context = DummyContext()
- view = lambda *arg: None
- self._callFUT(context, 'repoze.view', IDummy, view=view,
- request_type='GET')
- actions = context.actions
- self.assertEqual(len(actions), 1)
- action = actions[0]
- discrim = ('view', IDummy, '', None, IView, None, None, 'GET', None,
- None, False, None, None, None)
- self.assertEqual(action['discriminator'], discrim)
- register = action['callable']
- register()
- reg = get_current_registry()
- wrapper = reg.adapters.lookup(
- (IViewClassifier, IRequest, IDummy), IView, name='')
- request = DummyRequest()
- request.method = 'GET'
- self.assertEqual(wrapper.__predicated__(None, request), True)
- request.method = 'POST'
- self.assertEqual(wrapper.__predicated__(None, request), False)
-
- def test_request_type_asinterfacestring(self):
- from zope.interface import directlyProvides
- from pyramid.threadlocal import get_current_registry
- from pyramid.interfaces import IView
- from pyramid.interfaces import IViewClassifier
- from pyramid.interfaces import IRequest
- context = DummyContext(IDummy)
- view = lambda *arg: 'OK'
- self._callFUT(context, 'repoze.view', IDummy, view=view,
- request_type='whatever')
- actions = context.actions
- self.assertEqual(len(actions), 1)
- discrim = ('view', IDummy, '', IDummy, IView, None, None, None, None,
- None, False, None, None, None)
- self.assertEqual(actions[0]['discriminator'], discrim)
- register = actions[0]['callable']
- register()
- reg = get_current_registry()
- regview = reg.adapters.lookup(
- (IViewClassifier, IRequest, IDummy), IView, name='')
- self.assertNotEqual(view, regview)
- request = DummyRequest()
- directlyProvides(request, IDummy)
- result = regview(None, request)
- self.assertEqual(result, 'OK')
- self.failIf(hasattr(view, '__call_permissive__'))
-
- def test_request_type_asnoninterfacestring(self):
- from pyramid.exceptions import ConfigurationError
- context = DummyContext('notaninterface')
- view = lambda *arg: 'OK'
- self.assertRaises(ConfigurationError,
- self._callFUT,
- context, 'repoze.view', IDummy, view=view,
- request_type='whatever')
-
def test_with_dotted_renderer(self):
from pyramid.threadlocal import get_current_registry
from pyramid.interfaces import IView
diff --git a/pyramid/zcml.py b/pyramid/zcml.py
index e2ea64d9b..c955c34ee 100644
--- a/pyramid/zcml.py
+++ b/pyramid/zcml.py
@@ -6,7 +6,6 @@ from zope.configuration.fields import GlobalInterface
from zope.configuration.fields import GlobalObject
from zope.configuration.fields import Tokens
-from zope.interface.interfaces import IInterface
from zope.interface import Interface
from zope.interface import implementedBy
from zope.interface import providedBy
@@ -84,8 +83,8 @@ class IViewDirective(Interface):
description = u'',
required=False)
- request_type = TextLine(
- title=u"The request type string or dotted name interface for the view",
+ request_type = GlobalObject(
+ title=u"The dotted name interface for the request type",
description=(u"The view will be called if the interface represented by "
u"'request_type' is implemented by the request. The "
u"default request type is pyramid.interfaces.IRequest"),
@@ -103,9 +102,7 @@ class IViewDirective(Interface):
request_method = TextLine(
title = u'Request method name that must be matched (e.g. GET/POST)',
description = (u'The view will be called if and only if the request '
- 'method (``request.method``) matches this string. This'
- 'functionality replaces the older ``request_type`` '
- 'functionality.'),
+ 'method (``request.method``) matches this string.'),
required=False)
request_param = TextLine(
@@ -177,17 +174,6 @@ def view(
reg = get_current_registry()
- if request_type in ('GET', 'HEAD', 'PUT', 'POST', 'DELETE'):
- # b/w compat for 1.0
- request_method = request_type
- request_type = None
-
- if request_type is not None:
- request_type = _context.resolve(request_type)
- if not IInterface.providedBy(request_type):
- raise ConfigurationError(
- 'request_type must be an interface, not %s' % request_type)
-
if renderer is not None:
package = getattr(_context, 'package', None)
renderer = {'name':renderer, 'package':package}