Chris McDonough
2013-09-10 75f3857c811c61b9461c6ba31e8147e403bf80e6
- 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.
3 files modified
120 ■■■■■ changed files
CHANGES.txt 7 ●●●●● patch | view | raw | blame | history
pyramid/config/factories.py 8 ●●●● patch | view | raw | blame | history
pyramid/tests/test_config/test_factories.py 105 ●●●●● patch | view | raw | blame | history
CHANGES.txt
@@ -117,6 +117,13 @@
  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)
==================
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 @@
                        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
        """
pyramid/tests/test_config/test_factories.py
@@ -67,51 +67,6 @@
        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 @@
        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)