Michael Merickel
2016-11-15 9c8d43a7101c2977f6bf388758f14c7c7fadcf71
turn on warnings by default for ``pyramid.deprecation.RemoveInVersion19Warning``
1 files added
10 files modified
231 ■■■■■ changed files
pyramid/config/factories.py 9 ●●●● patch | view | raw | blame | history
pyramid/config/routes.py 4 ●●● patch | view | raw | blame | history
pyramid/config/settings.py 17 ●●●●● patch | view | raw | blame | history
pyramid/config/views.py 9 ●●●● patch | view | raw | blame | history
pyramid/deprecation.py 9 ●●●●● patch | view | raw | blame | history
pyramid/i18n.py 18 ●●●●● patch | view | raw | blame | history
pyramid/interfaces.py 12 ●●●●● patch | view | raw | blame | history
pyramid/scripts/common.py 12 ●●●●● patch | view | raw | blame | history
pyramid/security.py 19 ●●●●● patch | view | raw | blame | history
pyramid/session.py 112 ●●●●● patch | view | raw | blame | history
pyramid/traversal.py 10 ●●●● patch | view | raw | blame | history
pyramid/config/factories.py
@@ -1,5 +1,9 @@
from zope.deprecation import deprecated
from zope.interface import implementer
from pyramid.deprecation import (
    RemoveInPyramid19Warning,
    deprecated,
)
from pyramid.interfaces import (
    IDefaultRootFactory,
@@ -229,7 +233,8 @@
    deprecated(
        set_request_property,
        'set_request_propery() is deprecated as of Pyramid 1.5; use '
        'add_request_method() with the property=True argument instead')
        'add_request_method() with the property=True argument instead',
        RemoveInPyramid19Warning)
@implementer(IRequestExtensions)
pyramid/config/routes.py
@@ -1,5 +1,7 @@
import warnings
from pyramid.deprecation import RemoveInPyramid19Warning
from pyramid.compat import urlparse
from pyramid.interfaces import (
    IRequest,
@@ -285,7 +287,7 @@
                 'instead. See "Adding A Third Party View, Route, or '
                 'Subscriber Predicate" in the "Hooks" chapter of the '
                 'documentation for more information.'),
                DeprecationWarning,
                RemoveInPyramid19Warning,
                stacklevel=3
                )
        # these are route predicates; if they do not match, the next route
pyramid/config/settings.py
@@ -1,5 +1,4 @@
import os
import warnings
from zope.interface import implementer
@@ -152,20 +151,4 @@
        }
        self.update(update)
    def __getattr__(self, name):
        try:
            val = self[name]
            # only deprecate on success; a probing getattr/hasattr should not
            # print this warning
            warnings.warn(
                'Obtaining settings via attributes of the settings dictionary '
                'is deprecated as of Pyramid 1.2; use settings["foo"] instead '
                'of settings.foo',
                DeprecationWarning,
                2
                )
            return val
        except KeyError:
            raise AttributeError(name)
pyramid/config/views.py
@@ -11,6 +11,11 @@
    )
from zope.interface.interfaces import IInterface
from pyramid.deprecation import (
    RemoveInPyramid19Warning,
    RemoveInPyramid110Warning,
)
from pyramid.interfaces import (
    IExceptionViewClassifier,
    IException,
@@ -724,7 +729,7 @@
                 'See "Adding A Third Party View, Route, or Subscriber '
                 'Predicate" in the "Hooks" chapter of the documentation '
                 'for more information.'),
                DeprecationWarning,
                RemoveInPyramid19Warning,
                stacklevel=4,
                )
@@ -735,7 +740,7 @@
                 'instead or see "Checking CSRF Tokens Automatically" in the '
                 '"Sessions" chapter of the documentation for more '
                 'information.'),
                DeprecationWarning,
                RemoveInPyramid110Warning,
                stacklevel=4,
                )
pyramid/deprecation.py
New file
@@ -0,0 +1,9 @@
from zope.deprecation import deprecated  # noqa, internal api
class RemoveInPyramid19Warning(DeprecationWarning):
    pass
class RemoveInPyramid110Warning(DeprecationWarning):
    pass
RemovedInNextVersionWarning = RemoveInPyramid19Warning
pyramid/i18n.py
@@ -10,6 +10,10 @@
from pyramid.compat import PY2
from pyramid.decorator import reify
from pyramid.deprecation import (
    RemoveInPyramid19Warning,
    deprecated,
)
from pyramid.interfaces import (
    ILocalizer,
@@ -166,6 +170,13 @@
    """
    return request.locale_name
deprecated(
    'get_locale_name',
    'As of Pyramid 1.5 the "pyramid.i18n.get_locale_name" function is '
    'scheduled to be removed. Use "request.locale_name" instead.',
    RemoveInPyramid19Warning,
)
def make_localizer(current_locale_name, translation_directories):
    """ Create a :class:`pyramid.i18n.Localizer` object
    corresponding to the provided locale name from the 
@@ -218,6 +229,13 @@
    """
    return request.localizer
deprecated(
    'get_localizer',
    'As of Pyramid 1.5 the "pyramid.i18n.get_localizer" method is scheduled '
    'to be removed. Use "request.locale_name" instead.',
    RemoveInPyramid19Warning,
)
class Translations(gettext.GNUTranslations, object):
    """An extended translation catalog class (ripped off from Babel) """
pyramid/interfaces.py
@@ -1,11 +1,13 @@
from zope.deprecation import deprecated
from zope.interface import (
    Attribute,
    Interface,
    )
from pyramid.compat import PY2
from pyramid.deprecation import (
    RemoveInPyramid19Warning,
    deprecated,
)
# public API interfaces
@@ -424,7 +426,8 @@
    'ITemplateRenderer',
    'As of Pyramid 1.5 the, "pyramid.interfaces.ITemplateRenderer" interface '
    'is scheduled to be removed. It was used by the Mako and Chameleon '
    'renderers which have been split into their own packages.'
    'renderers which have been split into their own packages.',
    RemoveInPyramid19Warning,
    )
class IViewMapper(Interface):
@@ -848,7 +851,8 @@
    'scheduled to be removed.   Use the '
    '"pyramid.config.Configurator.add_resource_url_adapter" method to register '
    'a class that implements "pyramid.interfaces.IResourceURL" instead. '
    'See the "What\'s new In Pyramid 1.3" document for more details.'
    'See the "What\'s new In Pyramid 1.3" document for more details.',
    RemoveInPyramid19Warning,
    )
class IPEP302Loader(Interface):
pyramid/scripts/common.py
@@ -1,6 +1,11 @@
import os
from pyramid.compat import configparser
import logging
from logging.config import fileConfig
import sys
import warnings
from pyramid.compat import configparser
from pyramid.deprecation import RemoveInNextVersionWarning
def parse_vars(args):
    """
@@ -29,6 +34,11 @@
    and ``here`` variables, similar to PasteDeploy config loading.
    Extra defaults can optionally be specified as a dict in ``global_conf``.
    """
    logging.captureWarnings(True)
    if not sys.warnoptions:
        warnings.simplefilter('default', RemoveInNextVersionWarning)
    path = config_uri.split('#', 1)[0]
    parser = configparser.ConfigParser()
    parser.read([path])
pyramid/security.py
@@ -1,6 +1,9 @@
from zope.deprecation import deprecated
from zope.interface import providedBy
from pyramid.deprecation import (
    RemoveInPyramid19Warning,
    deprecated,
)
from pyramid.interfaces import (
    IAuthenticationPolicy,
    IAuthorizationPolicy,
@@ -62,7 +65,8 @@
    'has_permission',
    'As of Pyramid 1.5 the "pyramid.security.has_permission" API is now '
    'deprecated.  It will be removed in Pyramid 1.8.  Use the '
    '"has_permission" method of the Pyramid request instead.'
    '"has_permission" method of the Pyramid request instead.',
    RemoveInPyramid19Warning,
    )
@@ -80,7 +84,8 @@
    'authenticated_userid',
    'As of Pyramid 1.5 the "pyramid.security.authenticated_userid" API is now '
    'deprecated.  It will be removed in Pyramid 1.8.  Use the '
    '"authenticated_userid" attribute of the Pyramid request instead.'
    '"authenticated_userid" attribute of the Pyramid request instead.',
    RemoveInPyramid19Warning,
    )
def unauthenticated_userid(request):
@@ -97,7 +102,8 @@
    'unauthenticated_userid',
    'As of Pyramid 1.5 the "pyramid.security.unauthenticated_userid" API is '
    'now deprecated.  It will be removed in Pyramid 1.8.  Use the '
    '"unauthenticated_userid" attribute of the Pyramid request instead.'
    '"unauthenticated_userid" attribute of the Pyramid request instead.',
    RemoveInPyramid19Warning,
    )
def effective_principals(request):
@@ -114,7 +120,8 @@
    'effective_principals',
    'As of Pyramid 1.5 the "pyramid.security.effective_principals" API is '
    'now deprecated.  It will be removed in Pyramid 1.8.  Use the '
    '"effective_principals" attribute of the Pyramid request instead.'
    '"effective_principals" attribute of the Pyramid request instead.',
    RemoveInPyramid19Warning,
    )
def remember(request, userid=_marker, **kw):
@@ -156,7 +163,7 @@
                'principal',
                'The "principal" argument was deprecated in Pyramid 1.6. '
                'It will be removed in Pyramid 1.9. Use the "userid" '
                'argument instead.')
                'argument instead.', RemoveInPyramid19Warning)
            userid = principal
    policy = _get_authentication_policy(request)
    if policy is None:
pyramid/session.py
@@ -5,7 +5,6 @@
import os
import time
from zope.deprecation import deprecated
from zope.interface import implementer
from webob.cookies import SignedSerializer
@@ -518,117 +517,6 @@
            return True
    return CookieSession
def UnencryptedCookieSessionFactoryConfig(
    secret,
    timeout=1200,
    cookie_name='session',
    cookie_max_age=None,
    cookie_path='/',
    cookie_domain=None,
    cookie_secure=False,
    cookie_httponly=False,
    cookie_on_exception=True,
    signed_serialize=signed_serialize,
    signed_deserialize=signed_deserialize,
    ):
    """
    .. deprecated:: 1.5
        Use :func:`pyramid.session.SignedCookieSessionFactory` instead.
        Caveat: Cookies generated using ``SignedCookieSessionFactory`` are not
        compatible with cookies generated using
        ``UnencryptedCookieSessionFactory``, so existing user session data
        will be destroyed if you switch to it.
    Configure a :term:`session factory` which will provide unencrypted
    (but signed) cookie-based sessions.  The return value of this
    function is a :term:`session factory`, which may be provided as
    the ``session_factory`` argument of a
    :class:`pyramid.config.Configurator` constructor, or used
    as the ``session_factory`` argument of the
    :meth:`pyramid.config.Configurator.set_session_factory`
    method.
    The session factory returned by this function will create sessions
    which are limited to storing fewer than 4000 bytes of data (as the
    payload must fit into a single cookie).
    Parameters:
    ``secret``
      A string which is used to sign the cookie.
    ``timeout``
      A number of seconds of inactivity before a session times out.
    ``cookie_name``
      The name of the cookie used for sessioning.
    ``cookie_max_age``
      The maximum age of the cookie used for sessioning (in seconds).
      Default: ``None`` (browser scope).
    ``cookie_path``
      The path used for the session cookie.
    ``cookie_domain``
      The domain used for the session cookie.  Default: ``None`` (no domain).
    ``cookie_secure``
      The 'secure' flag of the session cookie.
    ``cookie_httponly``
      The 'httpOnly' flag of the session cookie.
    ``cookie_on_exception``
      If ``True``, set a session cookie even if an exception occurs
      while rendering a view.
    ``signed_serialize``
      A callable which takes more or less arbitrary Python data structure and
      a secret and returns a signed serialization in bytes.
      Default: ``signed_serialize`` (using pickle).
    ``signed_deserialize``
      A callable which takes a signed and serialized data structure in bytes
      and a secret and returns the original data structure if the signature
      is valid. Default: ``signed_deserialize`` (using pickle).
    """
    class SerializerWrapper(object):
        def __init__(self, secret):
            self.secret = secret
        def loads(self, bstruct):
            return signed_deserialize(bstruct, secret)
        def dumps(self, appstruct):
            return signed_serialize(appstruct, secret)
    serializer = SerializerWrapper(secret)
    return BaseCookieSessionFactory(
        serializer,
        cookie_name=cookie_name,
        max_age=cookie_max_age,
        path=cookie_path,
        domain=cookie_domain,
        secure=cookie_secure,
        httponly=cookie_httponly,
        timeout=timeout,
        reissue_time=0, # to keep session.accessed == session.renewed
        set_on_exception=cookie_on_exception,
    )
deprecated(
    'UnencryptedCookieSessionFactoryConfig',
    'The UnencryptedCookieSessionFactoryConfig callable is deprecated as of '
    'Pyramid 1.5.  Use ``pyramid.session.SignedCookieSessionFactory`` instead.'
    ' Caveat: Cookies generated using SignedCookieSessionFactory are not '
    'compatible with cookies generated using UnencryptedCookieSessionFactory, '
    'so existing user session data will be destroyed if you switch to it.'
    )
def SignedCookieSessionFactory(
    secret,
pyramid/traversal.py
@@ -1,11 +1,14 @@
import warnings
from zope.deprecation import deprecated
from zope.interface import implementer
from zope.interface.interfaces import IInterface
from repoze.lru import lru_cache
from pyramid.deprecation import (
    RemoveInPyramid19Warning,
    deprecated,
)
from pyramid.interfaces import (
    IResourceURL,
@@ -811,7 +814,8 @@
    'scheduled to be removed.   Use the '
    '"pyramid.config.Configurator.add_resource_url_adapter" method to register '
    'a class that implements "pyramid.interfaces.IResourceURL" instead. '
    'See the "What\'s new In Pyramid 1.3" document for a further description.'
    'See the "What\'s new In Pyramid 1.3" document for a further description.',
    RemoveInPyramid19Warning,
    )
@lru_cache(1000)