Permalink
Browse files

- The ``pyramid.config.Configurator.set_request_property`` method now…

… issues

  a deprecation warning when used.  It had been docs-deprecated in 1.4
  but did not issue a deprecation warning when used.
  • Loading branch information...
1 parent 27190e5 commit 75f3857c811c61b9461c6ba31e8147e403bf80e6 @mcdonc mcdonc committed Sep 10, 2013
Showing with 73 additions and 47 deletions.
  1. +7 −0 CHANGES.txt
  2. +6 −2 pyramid/config/factories.py
  3. +60 −45 pyramid/tests/test_config/test_factories.py
View
@@ -117,6 +117,13 @@ Backwards Incompatibilities
Pyramid narrative documentation instead of providing renderer globals values
to the configurator.
+Deprecations
+------------
+
+- The ``pyramid.config.Configurator.set_request_property`` method now issues
+ a deprecation warning when used. It had been docs-deprecated in 1.4
+ but did not issue a deprecation warning when used.
+
1.5a1 (2013-08-30)
==================
@@ -1,3 +1,4 @@
+from zope.deprecation import deprecate
from zope.interface import implementer
from pyramid.interfaces import (
@@ -179,12 +180,15 @@ def register():
introspectables=(intr,))
@action_method
+ @deprecate('set_request_propery() is deprecated as of Pyramid 1.5; use '
+ 'add_request_method() with the property=True argument instead')
def set_request_property(self, callable, name=None, reify=False):
""" Add a property to the request object.
- .. deprecated:: 1.4
+ .. deprecated:: 1.5
:meth:`pyramid.config.Configurator.add_request_method` should be
- used instead.
+ used instead. (This method was docs-deprecated in 1.4 and
+ issues a real deprecation warning in 1.5).
.. versionadded:: 1.3
"""
@@ -67,51 +67,6 @@ def test_set_session_factory_dottedname(self):
self.assertEqual(config.registry.getUtility(ISessionFactory),
dummyfactory)
- def test_set_request_property_with_callable(self):
- from pyramid.interfaces import IRequestExtensions
- config = self._makeOne(autocommit=True)
- callable = lambda x: None
- config.set_request_property(callable, name='foo')
- exts = config.registry.getUtility(IRequestExtensions)
- self.assertTrue('foo' in exts.descriptors)
-
- def test_set_request_property_with_unnamed_callable(self):
- from pyramid.interfaces import IRequestExtensions
- config = self._makeOne(autocommit=True)
- def foo(self): pass
- config.set_request_property(foo, reify=True)
- exts = config.registry.getUtility(IRequestExtensions)
- self.assertTrue('foo' in exts.descriptors)
-
- def test_set_request_property_with_property(self):
- from pyramid.interfaces import IRequestExtensions
- config = self._makeOne(autocommit=True)
- callable = property(lambda x: None)
- config.set_request_property(callable, name='foo')
- exts = config.registry.getUtility(IRequestExtensions)
- self.assertTrue('foo' in exts.descriptors)
-
- def test_set_multiple_request_properties(self):
- from pyramid.interfaces import IRequestExtensions
- config = self._makeOne()
- def foo(self): pass
- bar = property(lambda x: None)
- config.set_request_property(foo, reify=True)
- config.set_request_property(bar, name='bar')
- config.commit()
- exts = config.registry.getUtility(IRequestExtensions)
- self.assertTrue('foo' in exts.descriptors)
- self.assertTrue('bar' in exts.descriptors)
-
- def test_set_multiple_request_properties_conflict(self):
- from pyramid.exceptions import ConfigurationConflictError
- config = self._makeOne()
- def foo(self): pass
- bar = property(lambda x: None)
- config.set_request_property(foo, name='bar', reify=True)
- config.set_request_property(bar, name='bar')
- self.assertRaises(ConfigurationConflictError, config.commit)
-
def test_add_request_method_with_callable(self):
from pyramid.interfaces import IRequestExtensions
config = self._makeOne(autocommit=True)
@@ -157,3 +112,63 @@ def test_add_request_method_with_None_callable_and_no_name(self):
self.assertRaises(AttributeError, config.add_request_method)
+class TestDeprecatedFactoriesMixinMethods(unittest.TestCase):
+ def setUp(self):
+ from zope.deprecation import __show__
+ __show__.off()
+
+ def tearDown(self):
+ from zope.deprecation import __show__
+ __show__.on()
+
+ def _makeOne(self, *arg, **kw):
+ from pyramid.config import Configurator
+ config = Configurator(*arg, **kw)
+ return config
+
+ def test_set_request_property_with_callable(self):
+ from pyramid.interfaces import IRequestExtensions
+ config = self._makeOne(autocommit=True)
+ callable = lambda x: None
+ config.set_request_property(callable, name='foo')
+ exts = config.registry.getUtility(IRequestExtensions)
+ self.assertTrue('foo' in exts.descriptors)
+
+ def test_set_request_property_with_unnamed_callable(self):
+ from pyramid.interfaces import IRequestExtensions
+ config = self._makeOne(autocommit=True)
+ def foo(self): pass
+ config.set_request_property(foo, reify=True)
+ exts = config.registry.getUtility(IRequestExtensions)
+ self.assertTrue('foo' in exts.descriptors)
+
+ def test_set_request_property_with_property(self):
+ from pyramid.interfaces import IRequestExtensions
+ config = self._makeOne(autocommit=True)
+ callable = property(lambda x: None)
+ config.set_request_property(callable, name='foo')
+ exts = config.registry.getUtility(IRequestExtensions)
+ self.assertTrue('foo' in exts.descriptors)
+
+ def test_set_multiple_request_properties(self):
+ from pyramid.interfaces import IRequestExtensions
+ config = self._makeOne()
+ def foo(self): pass
+ bar = property(lambda x: None)
+ config.set_request_property(foo, reify=True)
+ config.set_request_property(bar, name='bar')
+ config.commit()
+ exts = config.registry.getUtility(IRequestExtensions)
+ self.assertTrue('foo' in exts.descriptors)
+ self.assertTrue('bar' in exts.descriptors)
+
+ def test_set_multiple_request_properties_conflict(self):
+ from pyramid.exceptions import ConfigurationConflictError
+ config = self._makeOne()
+ def foo(self): pass
+ bar = property(lambda x: None)
+ config.set_request_property(foo, name='bar', reify=True)
+ config.set_request_property(bar, name='bar')
+ self.assertRaises(ConfigurationConflictError, config.commit)
+
+

0 comments on commit 75f3857

Please sign in to comment.