turn on warnings by default for ``pyramid.deprecation.RemoveInVersion19Warning``
1 files added
10 files modified
| | |
| | | from zope.deprecation import deprecated |
| | | from zope.interface import implementer |
| | | |
| | | from pyramid.deprecation import ( |
| | | RemoveInPyramid19Warning, |
| | | deprecated, |
| | | ) |
| | | |
| | | from pyramid.interfaces import ( |
| | | IDefaultRootFactory, |
| | |
| | | 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) |
| | |
| | | import warnings |
| | | |
| | | from pyramid.deprecation import RemoveInPyramid19Warning |
| | | |
| | | from pyramid.compat import urlparse |
| | | from pyramid.interfaces import ( |
| | | IRequest, |
| | |
| | | '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 |
| | |
| | | import os |
| | | import warnings |
| | | |
| | | from zope.interface import implementer |
| | | |
| | |
| | | } |
| | | |
| | | 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) |
| | | |
| | |
| | | ) |
| | | from zope.interface.interfaces import IInterface |
| | | |
| | | from pyramid.deprecation import ( |
| | | RemoveInPyramid19Warning, |
| | | RemoveInPyramid110Warning, |
| | | ) |
| | | |
| | | from pyramid.interfaces import ( |
| | | IExceptionViewClassifier, |
| | | IException, |
| | |
| | | 'See "Adding A Third Party View, Route, or Subscriber ' |
| | | 'Predicate" in the "Hooks" chapter of the documentation ' |
| | | 'for more information.'), |
| | | DeprecationWarning, |
| | | RemoveInPyramid19Warning, |
| | | stacklevel=4, |
| | | ) |
| | | |
| | |
| | | 'instead or see "Checking CSRF Tokens Automatically" in the ' |
| | | '"Sessions" chapter of the documentation for more ' |
| | | 'information.'), |
| | | DeprecationWarning, |
| | | RemoveInPyramid110Warning, |
| | | stacklevel=4, |
| | | ) |
| | | |
New file |
| | |
| | | from zope.deprecation import deprecated # noqa, internal api |
| | | |
| | | class RemoveInPyramid19Warning(DeprecationWarning): |
| | | pass |
| | | |
| | | class RemoveInPyramid110Warning(DeprecationWarning): |
| | | pass |
| | | |
| | | RemovedInNextVersionWarning = RemoveInPyramid19Warning |
| | |
| | | |
| | | from pyramid.compat import PY2 |
| | | from pyramid.decorator import reify |
| | | from pyramid.deprecation import ( |
| | | RemoveInPyramid19Warning, |
| | | deprecated, |
| | | ) |
| | | |
| | | from pyramid.interfaces import ( |
| | | ILocalizer, |
| | |
| | | """ |
| | | 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 |
| | |
| | | """ |
| | | 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) """ |
| | | |
| | |
| | | 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 |
| | | |
| | |
| | | '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): |
| | |
| | | '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): |
| | |
| | | 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): |
| | | """ |
| | |
| | | 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]) |
| | |
| | | from zope.deprecation import deprecated |
| | | from zope.interface import providedBy |
| | | |
| | | from pyramid.deprecation import ( |
| | | RemoveInPyramid19Warning, |
| | | deprecated, |
| | | ) |
| | | from pyramid.interfaces import ( |
| | | IAuthenticationPolicy, |
| | | IAuthorizationPolicy, |
| | |
| | | '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, |
| | | ) |
| | | |
| | | |
| | |
| | | '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): |
| | |
| | | '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): |
| | |
| | | '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): |
| | |
| | | '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: |
| | |
| | | import os |
| | | import time |
| | | |
| | | from zope.deprecation import deprecated |
| | | from zope.interface import implementer |
| | | |
| | | from webob.cookies import SignedSerializer |
| | |
| | | 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, |
| | |
| | | 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, |
| | |
| | | '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) |