Michael Merickel
2018-10-04 35b2e933813ea596262f15d3672b5ab5e4a13c04
Merge pull request #3368 from mmerickel/remove-set-request-property

remove deprecated set_request_property
8 files modified
93 ■■■■■ changed files
CHANGES.rst 4 ●●●● patch | view | raw | blame | history
TODO.txt 1 ●●●● patch | view | raw | blame | history
docs/api/config.rst 1 ●●●● patch | view | raw | blame | history
docs/api/request.rst 3 ●●●● patch | view | raw | blame | history
docs/narr/advconfig.rst 1 ●●●● patch | view | raw | blame | history
docs/narr/subrequest.rst 3 ●●●● patch | view | raw | blame | history
pyramid/config/factories.py 20 ●●●●● patch | view | raw | blame | history
pyramid/tests/test_config/test_factories.py 60 ●●●●● patch | view | raw | blame | history
CHANGES.rst
@@ -131,6 +131,10 @@
  of previous ``pyramid.httpexceptions.HTTPFound``.
  See https://github.com/Pylons/pyramid/pull/3328
- Removed ``pyramid.config.Configurator.set_request_property`` which had been
  deprecated since Pyramid 1.5.
  See https://github.com/Pylons/pyramid/pull/3368
Documentation Changes
---------------------
TODO.txt
@@ -114,7 +114,6 @@
Future
------
- 1.9: Remove set_request_property.
- 1.9: Remove extra code enabling ``pyramid.security.remember(principal=...)``
  and force use of ``userid``.
docs/api/config.rst
@@ -44,7 +44,6 @@
   :methodcategory:`Extending the Request Object`
     .. automethod:: add_request_method
     .. automethod:: set_request_property
   :methodcategory:`Using I18N`
docs/api/request.rst
@@ -228,8 +228,7 @@
        handed.
      - sets request extensions (such as those added via
        :meth:`~pyramid.config.Configurator.add_request_method` or
        :meth:`~pyramid.config.Configurator.set_request_property`) on the
        :meth:`~pyramid.config.Configurator.add_request_method`) on the
        request it's passed.
      - causes a :class:`~pyramid.events.NewRequest` event to be sent at the
docs/narr/advconfig.rst
@@ -299,7 +299,6 @@
: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_property`,
:meth:`~pyramid.config.Configurator.set_root_factory`,
:meth:`~pyramid.config.Configurator.set_view_mapper`,
:meth:`~pyramid.config.Configurator.set_authentication_policy`,
docs/narr/subrequest.rst
@@ -232,8 +232,7 @@
  callable) to the request object to which it is handed.
- It sets request extensions (such as those added via
  :meth:`~pyramid.config.Configurator.add_request_method` or
  :meth:`~pyramid.config.Configurator.set_request_property`) on the subrequest
  :meth:`~pyramid.config.Configurator.add_request_method`) on the subrequest
  object passed as ``request``.
- It causes a :class:`~pyramid.events.NewRequest` event to be sent at the
pyramid/config/factories.py
@@ -1,4 +1,3 @@
from zope.deprecation import deprecated
from zope.interface import implementer
from pyramid.interfaces import (
@@ -214,25 +213,6 @@
            intr['reify'] = False
            self.action(('request extensions', name), register,
                        introspectables=(intr,))
    @action_method
    def set_request_property(self, callable, name=None, reify=False):
        """ Add a property to the request object.
        .. deprecated:: 1.5
            :meth:`pyramid.config.Configurator.add_request_method` should be
            used instead.  (This method was docs-deprecated in 1.4 and
            issues a real deprecation warning in 1.5).
        .. versionadded:: 1.3
        """
        self.add_request_method(
            callable, name=name, property=not reify, reify=reify)
    deprecated(
        set_request_property,
        'set_request_propery() is deprecated as of Pyramid 1.5; use '
        'add_request_method() with the property=True argument instead')
    @action_method
    def set_execution_policy(self, policy):
pyramid/tests/test_config/test_factories.py
@@ -161,63 +161,3 @@
        registry = config.registry
        result = registry.queryUtility(IExecutionPolicy)
        self.assertEqual(result, default_execution_policy)
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)