diff options
| -rw-r--r-- | CHANGES.txt | 4 | ||||
| -rw-r--r-- | TODO.txt | 4 | ||||
| -rw-r--r-- | docs/api/config.rst | 2 | ||||
| -rw-r--r-- | docs/narr/advconfig.rst | 2 | ||||
| -rw-r--r-- | pyramid/config/factories.py | 6 | ||||
| -rw-r--r-- | pyramid/tests/test_config/test_factories.py | 30 |
6 files changed, 24 insertions, 24 deletions
diff --git a/CHANGES.txt b/CHANGES.txt index eedf50d14..95a435ef4 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -87,7 +87,7 @@ Features HEAD is a variant of GET that omits the body, and WebOb has special support to return an empty body when a HEAD is used. -- ``config.set_request_method`` has been introduced to support extending +- ``config.add_request_method`` has been introduced to support extending request objects with arbitrary callables. This method expands on the previous ``config.set_request_property`` by supporting methods as well as properties. This method now causes less code to be executed at @@ -149,7 +149,7 @@ Deprecations - The ``pyramid.config.Configurator.set_request_property`` has been documentation-deprecated. The method remains usable but the more - featureful ``pyramid.config.Configurator.set_request_method`` should be + featureful ``pyramid.config.Configurator.add_request_method`` should be used in its place (it has all of the same capabilities but can also extend the request object with methods). @@ -106,8 +106,8 @@ Future - 1.5: Remove ``pyramid.requests.DeprecatedRequestMethodsMixin``. -- 1.6: Maybe? deprecate set_request_property in favor of pointing people at - set_request_method. +- 1.5: Maybe? deprecate set_request_property in favor of pointing people at + add_request_method, schedule removal for 1.8? - 1.6: Remove IContextURL and TraversalContextURL. diff --git a/docs/api/config.rst b/docs/api/config.rst index 028a55d4b..5d2bce23e 100644 --- a/docs/api/config.rst +++ b/docs/api/config.rst @@ -40,7 +40,7 @@ :methodcategory:`Extending the Request Object` - .. automethod:: set_request_method + .. automethod:: add_request_method .. automethod:: set_request_property :methodcategory:`Using I18N` diff --git a/docs/narr/advconfig.rst b/docs/narr/advconfig.rst index b1ea652d6..165cf7474 100644 --- a/docs/narr/advconfig.rst +++ b/docs/narr/advconfig.rst @@ -294,9 +294,9 @@ These are the methods of the configurator which provide conflict detection: :meth:`~pyramid.config.Configurator.add_view`, :meth:`~pyramid.config.Configurator.add_route`, :meth:`~pyramid.config.Configurator.add_renderer`, +:meth:`~pyramid.config.Configurator.add_request_method`, :meth:`~pyramid.config.Configurator.set_request_factory`, :meth:`~pyramid.config.Configurator.set_session_factory`, -:meth:`~pyramid.config.Configurator.set_request_method`, :meth:`~pyramid.config.Configurator.set_request_property`, :meth:`~pyramid.config.Configurator.set_root_factory`, :meth:`~pyramid.config.Configurator.set_view_mapper`, diff --git a/pyramid/config/factories.py b/pyramid/config/factories.py index e8043ed28..fb26ea806 100644 --- a/pyramid/config/factories.py +++ b/pyramid/config/factories.py @@ -96,7 +96,7 @@ class FactoriesConfiguratorMixin(object): self.action(IRequestFactory, register, introspectables=(intr,)) @action_method - def set_request_method(self, + def add_request_method(self, callable=None, name=None, property=False, @@ -187,12 +187,12 @@ class FactoriesConfiguratorMixin(object): .. warning:: This method has been deprecated as of Pyramid 1.4. - :meth:`pyramid.config.Configurator.set_request_method` should be + :meth:`pyramid.config.Configurator.add_request_method` should be used instead. .. versionadded:: 1.3 """ - self.set_request_method( + self.add_request_method( callable, name=name, property=not reify, reify=reify) @implementer(IRequestExtensions) diff --git a/pyramid/tests/test_config/test_factories.py b/pyramid/tests/test_config/test_factories.py index 38e80416f..213b7af84 100644 --- a/pyramid/tests/test_config/test_factories.py +++ b/pyramid/tests/test_config/test_factories.py @@ -129,12 +129,12 @@ class TestFactoriesMixin(unittest.TestCase): self.assertEqual('bar', exts[0]) self.assertEqual('foo', exts[1]) - def test_set_request_method_subscriber(self): + def test_add_request_method_subscriber(self): from zope.interface import implementer from pyramid.interfaces import INewRequest config = self._makeOne(autocommit=True) def foo(r): return 'bar' - config.set_request_method(foo, name='foo') + config.add_request_method(foo, name='foo') @implementer(INewRequest) class Event(object): request = DummyRequest(config.registry) @@ -142,19 +142,19 @@ class TestFactoriesMixin(unittest.TestCase): config.registry.notify(event) self.assertEqual('bar', event.request.foo()) - def test_set_request_method_with_callable(self): + def test_add_request_method_with_callable(self): from pyramid.interfaces import IRequestExtensions config = self._makeOne(autocommit=True) callable = lambda x: None - config.set_request_method(callable, name='foo') + config.add_request_method(callable, name='foo') exts = config.registry.getUtility(IRequestExtensions) self.assertTrue('foo' in exts.methods) - def test_set_request_method_with_unnamed_callable(self): + def test_add_request_method_with_unnamed_callable(self): from pyramid.interfaces import IRequestExtensions config = self._makeOne(autocommit=True) def foo(self): pass - config.set_request_method(foo) + config.add_request_method(foo) exts = config.registry.getUtility(IRequestExtensions) self.assertTrue('foo' in exts.methods) @@ -163,28 +163,28 @@ class TestFactoriesMixin(unittest.TestCase): config = self._makeOne() def foo(self): pass def bar(self): pass - config.set_request_method(foo, name='bar') - config.set_request_method(bar, name='bar') + config.add_request_method(foo, name='bar') + config.add_request_method(bar, name='bar') self.assertRaises(ConfigurationConflictError, config.commit) - def test_set_request_method_with_None_callable(self): + def test_add_request_method_with_None_callable(self): from pyramid.interfaces import IRequestExtensions config = self._makeOne(autocommit=True) - config.set_request_method(name='foo') + config.add_request_method(name='foo') exts = config.registry.queryUtility(IRequestExtensions) self.assertTrue(exts is None) - def test_set_request_method_with_None_callable_conflict(self): + def test_add_request_method_with_None_callable_conflict(self): from pyramid.exceptions import ConfigurationConflictError config = self._makeOne() def bar(self): pass - config.set_request_method(name='foo') - config.set_request_method(bar, name='foo') + config.add_request_method(name='foo') + config.add_request_method(bar, name='foo') self.assertRaises(ConfigurationConflictError, config.commit) - def test_set_request_method_with_None_callable_and_no_name(self): + def test_add_request_method_with_None_callable_and_no_name(self): config = self._makeOne(autocommit=True) - self.assertRaises(AttributeError, config.set_request_method) + self.assertRaises(AttributeError, config.add_request_method) class DummyRequest(object): |
