summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGES.txt7
-rw-r--r--pyramid/config/factories.py8
-rw-r--r--pyramid/tests/test_config/test_factories.py105
3 files changed, 73 insertions, 47 deletions
diff --git a/CHANGES.txt b/CHANGES.txt
index 41549fbe5..5976a326f 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -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)
==================
diff --git a/pyramid/config/factories.py b/pyramid/config/factories.py
index d30df3b74..774125821 100644
--- a/pyramid/config/factories.py
+++ b/pyramid/config/factories.py
@@ -1,3 +1,4 @@
+from zope.deprecation import deprecate
from zope.interface import implementer
from pyramid.interfaces import (
@@ -179,12 +180,15 @@ class FactoriesConfiguratorMixin(object):
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
"""
diff --git a/pyramid/tests/test_config/test_factories.py b/pyramid/tests/test_config/test_factories.py
index e89fc077e..6e679397f 100644
--- a/pyramid/tests/test_config/test_factories.py
+++ b/pyramid/tests/test_config/test_factories.py
@@ -67,51 +67,6 @@ class TestFactoriesMixin(unittest.TestCase):
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 @@ class TestFactoriesMixin(unittest.TestCase):
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)
+
+