From 3b7334af6b33a462f9bab074b92541ab6ad23d2a Mon Sep 17 00:00:00 2001 From: Chris McDonough Date: Thu, 22 Sep 2011 21:25:56 -0400 Subject: implements->implementer --- pyramid/authentication.py | 10 +++++----- pyramid/authorization.py | 5 ++--- pyramid/chameleon_text.py | 4 ++-- pyramid/chameleon_zpt.py | 4 ++-- pyramid/compat.py | 5 +++++ pyramid/config/assets.py | 4 ++-- pyramid/config/settings.py | 4 ++-- pyramid/config/tweens.py | 4 ++-- pyramid/config/views.py | 8 ++++---- pyramid/events.py | 12 ++++++------ pyramid/httpexceptions.py | 4 ++-- pyramid/mako_templating.py | 4 ++-- pyramid/paster.py | 4 ++-- pyramid/renderers.py | 6 +++--- pyramid/request.py | 4 ++-- pyramid/response.py | 6 +++--- pyramid/router.py | 4 ++-- pyramid/session.py | 4 ++-- pyramid/testing.py | 6 +++--- pyramid/tests/test_config/__init__.py | 4 ++-- pyramid/tests/test_config/test_adapters.py | 14 ++++++++------ pyramid/tests/test_config/test_init.py | 24 ++++++++++++------------ pyramid/tests/test_config/test_testing.py | 5 +++-- pyramid/tests/test_config/test_views.py | 13 +++++++------ pyramid/tests/test_location.py | 4 ++-- pyramid/tests/test_paster.py | 28 +++++++++++++++------------- pyramid/tests/test_registry.py | 6 ++++-- pyramid/tests/test_router.py | 4 ++-- pyramid/tests/test_testing.py | 10 ++++++---- pyramid/tests/test_view.py | 8 +++++--- pyramid/traversal.py | 12 +++++++----- pyramid/urldispatch.py | 6 +++--- 32 files changed, 129 insertions(+), 111 deletions(-) diff --git a/pyramid/authentication.py b/pyramid/authentication.py index d3d5a1ecd..898cc77a7 100644 --- a/pyramid/authentication.py +++ b/pyramid/authentication.py @@ -7,7 +7,7 @@ import sys import time as time_mod import urllib -from zope.interface import implements +from zope.interface import implementer from pyramid.compat import long @@ -108,6 +108,7 @@ class CallbackAuthenticationPolicy(object): ) return effective_principals +@implementer(IAuthenticationPolicy) class RepozeWho1AuthenticationPolicy(CallbackAuthenticationPolicy): """ A :app:`Pyramid` :term:`authentication policy` which obtains data from the :mod:`repoze.who` 1.X WSGI 'API' (the @@ -132,7 +133,6 @@ class RepozeWho1AuthenticationPolicy(CallbackAuthenticationPolicy): Objects of this class implement the interface described by :class:`pyramid.interfaces.IAuthenticationPolicy`. """ - implements(IAuthenticationPolicy) def __init__(self, identifier_name='auth_tkt', callback=None): self.identifier_name = identifier_name @@ -196,6 +196,7 @@ class RepozeWho1AuthenticationPolicy(CallbackAuthenticationPolicy): identity = self._get_identity(request) return identifier.forget(request.environ, identity) +@implementer(IAuthenticationPolicy) class RemoteUserAuthenticationPolicy(CallbackAuthenticationPolicy): """ A :app:`Pyramid` :term:`authentication policy` which obtains data from the ``REMOTE_USER`` WSGI environment variable. @@ -225,7 +226,6 @@ class RemoteUserAuthenticationPolicy(CallbackAuthenticationPolicy): Objects of this class implement the interface described by :class:`pyramid.interfaces.IAuthenticationPolicy`. """ - implements(IAuthenticationPolicy) def __init__(self, environ_key='REMOTE_USER', callback=None, debug=False): self.environ_key = environ_key @@ -241,6 +241,7 @@ class RemoteUserAuthenticationPolicy(CallbackAuthenticationPolicy): def forget(self, request): return [] +@implementer(IAuthenticationPolicy) class AuthTktAuthenticationPolicy(CallbackAuthenticationPolicy): """ A :app:`Pyramid` :term:`authentication policy` which obtains data from an :class:`paste.auth.auth_tkt` cookie. @@ -343,7 +344,6 @@ class AuthTktAuthenticationPolicy(CallbackAuthenticationPolicy): Objects of this class implement the interface described by :class:`pyramid.interfaces.IAuthenticationPolicy`. """ - implements(IAuthenticationPolicy) def __init__(self, secret, callback=None, @@ -747,6 +747,7 @@ class AuthTktCookieHelper(object): cookie_value = ticket.cookie_value() return self._get_cookies(environ, cookie_value, max_age) +@implementer(IAuthenticationPolicy) class SessionAuthenticationPolicy(CallbackAuthenticationPolicy): """ A :app:`Pyramid` authentication policy which gets its data from the configured :term:`session`. For this authentication policy to work, you @@ -776,7 +777,6 @@ class SessionAuthenticationPolicy(CallbackAuthenticationPolicy): or IRC channels when asking for support. """ - implements(IAuthenticationPolicy) def __init__(self, prefix='auth.', callback=None, debug=False): self.callback = callback diff --git a/pyramid/authorization.py b/pyramid/authorization.py index ac8f195f2..b1ef10033 100644 --- a/pyramid/authorization.py +++ b/pyramid/authorization.py @@ -1,4 +1,4 @@ -from zope.interface import implements +from zope.interface import implementer from pyramid.interfaces import IAuthorizationPolicy @@ -9,6 +9,7 @@ from pyramid.security import Allow from pyramid.security import Deny from pyramid.security import Everyone +@implementer(IAuthorizationPolicy) class ACLAuthorizationPolicy(object): """ An :term:`authorization policy` which consults an :term:`ACL` object attached to a :term:`context` to determine authorization @@ -60,8 +61,6 @@ class ACLAuthorizationPolicy(object): :class:`pyramid.interfaces.IAuthorizationPolicy` interface. """ - implements(IAuthorizationPolicy) - def permits(self, context, principals, permission): """ Return an instance of :class:`pyramid.security.ACLAllowed` instance if the policy diff --git a/pyramid/chameleon_text.py b/pyramid/chameleon_text.py index bb6531976..0539e0f29 100644 --- a/pyramid/chameleon_text.py +++ b/pyramid/chameleon_text.py @@ -1,7 +1,7 @@ import sys from zope.deprecation import deprecated -from zope.interface import implements +from zope.interface import implementer from pyramid.compat import reraise @@ -25,8 +25,8 @@ from pyramid.path import caller_package def renderer_factory(info): return renderers.template_renderer_factory(info, TextTemplateRenderer) +@implementer(ITemplateRenderer) class TextTemplateRenderer(object): - implements(ITemplateRenderer) def __init__(self, path, lookup): self.path = path self.lookup = lookup diff --git a/pyramid/chameleon_zpt.py b/pyramid/chameleon_zpt.py index 495835c3d..dd1c47dcb 100644 --- a/pyramid/chameleon_zpt.py +++ b/pyramid/chameleon_zpt.py @@ -1,7 +1,7 @@ import sys from zope.deprecation import deprecated -from zope.interface import implements +from zope.interface import implementer from pyramid.compat import reraise @@ -24,8 +24,8 @@ from pyramid import renderers def renderer_factory(info): return renderers.template_renderer_factory(info, ZPTTemplateRenderer) +@implementer(ITemplateRenderer) class ZPTTemplateRenderer(object): - implements(ITemplateRenderer) def __init__(self, path, lookup): self.path = path self.lookup = lookup diff --git a/pyramid/compat.py b/pyramid/compat.py index 21e8df6a5..3a73b7e8f 100644 --- a/pyramid/compat.py +++ b/pyramid/compat.py @@ -182,3 +182,8 @@ if PY3: else: map_ = map +try: + import __pypy__ +except: + __pypy__ = None + diff --git a/pyramid/config/assets.py b/pyramid/config/assets.py index 1b5254072..08cc6dc38 100644 --- a/pyramid/config/assets.py +++ b/pyramid/config/assets.py @@ -1,7 +1,7 @@ import pkg_resources import sys -from zope.interface import implements +from zope.interface import implementer from pyramid.interfaces import IPackageOverrides @@ -80,8 +80,8 @@ class OverrideProvider(pkg_resources.DefaultProvider): return pkg_resources.DefaultProvider.resource_listdir( self, resource_name) +@implementer(IPackageOverrides) class PackageOverrides: - implements(IPackageOverrides) # pkg_resources arg in kw args below for testing def __init__(self, package, pkg_resources=pkg_resources): if hasattr(package, '__loader__') and not isinstance(package.__loader__, diff --git a/pyramid/config/settings.py b/pyramid/config/settings.py index 6e636bf58..565a6699c 100644 --- a/pyramid/config/settings.py +++ b/pyramid/config/settings.py @@ -1,7 +1,7 @@ import os import warnings -from zope.interface import implements +from zope.interface import implementer from pyramid.interfaces import ISettings @@ -54,12 +54,12 @@ class SettingsConfiguratorMixin(object): return self.registry.settings +@implementer(ISettings) class Settings(dict): """ Deployment settings. Update application settings (usually from PasteDeploy keywords) with framework-specific key/value pairs (e.g. find ``PYRAMID_DEBUG_AUTHORIZATION`` in os.environ and jam into keyword args).""" - implements(ISettings) # _environ_ is dep inj for testing def __init__(self, d=None, _environ_=os.environ, **kw): if d is None: diff --git a/pyramid/config/tweens.py b/pyramid/config/tweens.py index 6feb1bfe6..0cdc55e65 100644 --- a/pyramid/config/tweens.py +++ b/pyramid/config/tweens.py @@ -1,4 +1,4 @@ -from zope.interface import implements +from zope.interface import implementer from pyramid.interfaces import ITweens @@ -157,8 +157,8 @@ class CyclicDependencyError(Exception): msg = 'Implicit tween ordering cycle:' + '; '.join(L) return msg +@implementer(ITweens) class Tweens(object): - implements(ITweens) def __init__(self): self.explicit = [] self.names = [] diff --git a/pyramid/config/views.py b/pyramid/config/views.py index 203f2b5c6..d89431bda 100644 --- a/pyramid/config/views.py +++ b/pyramid/config/views.py @@ -3,7 +3,7 @@ import inspect from zope.interface import Interface from zope.interface import classProvides from zope.interface import implementedBy -from zope.interface import implements +from zope.interface import implementer from zope.interface.interfaces import IInterface from pyramid.interfaces import IAuthenticationPolicy @@ -335,9 +335,9 @@ class ViewDeriver(object): return view return decorator(view) +@implementer(IViewMapper) class DefaultViewMapper(object): classProvides(IViewMapperFactory) - implements(IViewMapper) def __init__(self, **kw): self.attr = kw.get('attr') @@ -459,8 +459,8 @@ def requestonly(view, attr=None): return False +@implementer(IMultiView) class MultiView(object): - implements(IMultiView) def __init__(self, name): self.name = name @@ -1403,8 +1403,8 @@ def isexception(o): ) +@implementer(IStaticURLInfo) class StaticURLInfo(object): - implements(IStaticURLInfo) def _get_registrations(self, registry): try: diff --git a/pyramid/events.py b/pyramid/events.py index 71e923c0f..45edb8d02 100644 --- a/pyramid/events.py +++ b/pyramid/events.py @@ -1,6 +1,6 @@ import venusian -from zope.interface import implements +from zope.interface import implementer from pyramid.interfaces import IContextFound from pyramid.interfaces import INewRequest @@ -71,16 +71,17 @@ class subscriber(object): self.venusian.attach(wrapped, self.register, category='pyramid') return wrapped +@implementer(INewRequest) class NewRequest(object): """ An instance of this class is emitted as an :term:`event` whenever :app:`Pyramid` begins to process a new request. The even instance has an attribute, ``request``, which is a :term:`request` object. This event class implements the :class:`pyramid.interfaces.INewRequest` interface.""" - implements(INewRequest) def __init__(self, request): self.request = request +@implementer(INewResponse) class NewResponse(object): """ An instance of this class is emitted as an :term:`event` whenever any :app:`Pyramid` :term:`view` or :term:`exception @@ -112,11 +113,11 @@ class NewResponse(object): almost purely for symmetry with the :class:`pyramid.interfaces.INewRequest` event. """ - implements(INewResponse) def __init__(self, request, response): self.request = request self.response = response +@implementer(IContextFound) class ContextFound(object): """ An instance of this class is emitted as an :term:`event` after the :app:`Pyramid` :term:`router` finds a :term:`context` @@ -136,12 +137,12 @@ class ContextFound(object): purposes, this event may also be imported as :class:`pyramid.events.AfterTraversal`. """ - implements(IContextFound) def __init__(self, request): self.request = request AfterTraversal = ContextFound # b/c as of 1.0 +@implementer(IApplicationCreated) class ApplicationCreated(object): """ An instance of this class is emitted as an :term:`event` when the :meth:`pyramid.config.Configurator.make_wsgi_app` is @@ -156,13 +157,13 @@ class ApplicationCreated(object): was the name of the event class before :app:`Pyramid` 1.0. """ - implements(IApplicationCreated) def __init__(self, app): self.app = app self.object = app WSGIApplicationCreatedEvent = ApplicationCreated # b/c (as of 1.0) +@implementer(IBeforeRender) class BeforeRender(dict): """ Subscribers to this event may introspect the and modify the set of @@ -200,7 +201,6 @@ class BeforeRender(dict): See also :class:`pyramid.interfaces.IBeforeRender`. """ - implements(IBeforeRender) def __init__(self, system, rendering_val=None): dict.__init__(self, system) self.rendering_val = rendering_val diff --git a/pyramid/httpexceptions.py b/pyramid/httpexceptions.py index 7cebfdc48..46bc1890c 100644 --- a/pyramid/httpexceptions.py +++ b/pyramid/httpexceptions.py @@ -124,7 +124,7 @@ field. Reflecting this, these subclasses have one additional keyword argument: from string import Template -from zope.interface import implements +from zope.interface import implementer from webob import html_escape as _html_escape @@ -145,8 +145,8 @@ def _no_escape(value): class HTTPException(Exception): # bw compat """ Base class for all :term:`exception response` objects.""" +@implementer(IExceptionResponse) class WSGIHTTPException(Response, HTTPException): - implements(IExceptionResponse) ## You should set in subclasses: # code = 200 diff --git a/pyramid/mako_templating.py b/pyramid/mako_templating.py index c79de7217..a12e72b86 100644 --- a/pyramid/mako_templating.py +++ b/pyramid/mako_templating.py @@ -2,7 +2,7 @@ import os import sys import threading -from zope.interface import implements +from zope.interface import implementer from zope.interface import Interface from pyramid.asset import resolve_asset_spec @@ -120,8 +120,8 @@ class MakoRenderingException(Exception): __str__ = __repr__ +@implementer(ITemplateRenderer) class MakoLookupTemplateRenderer(object): - implements(ITemplateRenderer) def __init__(self, path, lookup): self.path = path self.lookup = lookup diff --git a/pyramid/paster.py b/pyramid/paster.py index b419c1b16..4fc1812ca 100644 --- a/pyramid/paster.py +++ b/pyramid/paster.py @@ -378,7 +378,7 @@ class PViewsCommand(PCommand): configuration` within the application registry; return the view. """ from zope.interface import providedBy - from zope.interface import implements + from zope.interface import implementer from pyramid.interfaces import IRequest from pyramid.interfaces import IRootFactory from pyramid.interfaces import IRouteRequest @@ -399,8 +399,8 @@ class PViewsCommand(PCommand): adapters = registry.adapters request = None + @implementer(IMultiView) class RoutesMultiView(object): - implements(IMultiView) def __init__(self, infos, context_iface, root_factory, request): self.views = [] diff --git a/pyramid/renderers.py b/pyramid/renderers.py index 93e97de8f..04208fcdc 100644 --- a/pyramid/renderers.py +++ b/pyramid/renderers.py @@ -2,7 +2,7 @@ import os import pkg_resources import threading -from zope.interface import implements +from zope.interface import implementer from zope.deprecation import deprecated from pyramid.interfaces import IChameleonLookup @@ -227,8 +227,8 @@ class JSONP(object): # utility functions, not API +@implementer(IChameleonLookup) class ChameleonRendererLookup(object): - implements(IChameleonLookup) def __init__(self, impl, registry): self.impl = impl self.registry = registry @@ -350,8 +350,8 @@ deprecated( 'the next major release. To replace it, use the ' '``pyramid.renderers.get_renderer`` API instead. ') +@implementer(IRendererInfo) class RendererHelper(object): - implements(IRendererInfo) def __init__(self, name=None, package=None, registry=None): if name and '.' in name: rtype = os.path.splitext(name)[1] diff --git a/pyramid/request.py b/pyramid/request.py index 03717031d..8188eecf1 100644 --- a/pyramid/request.py +++ b/pyramid/request.py @@ -1,6 +1,6 @@ from zope.deprecation import deprecate from zope.deprecation.deprecation import deprecated -from zope.interface import implements +from zope.interface import implementer from zope.interface.interface import InterfaceClass from webob import BaseRequest @@ -283,6 +283,7 @@ class CallbackMethodsMixin(object): callback = callbacks.pop(0) callback(self) +@implementer(IRequest) class Request(BaseRequest, DeprecatedRequestMethodsMixin, URLMethodsMixin, CallbackMethodsMixin): """ @@ -305,7 +306,6 @@ class Request(BaseRequest, DeprecatedRequestMethodsMixin, URLMethodsMixin, release of this :app:`Pyramid` version. See http://pythonpaste.org/webob/ for further information. """ - implements(IRequest) exception = None exc_info = None matchdict = None diff --git a/pyramid/response.py b/pyramid/response.py index db53de0c3..b0c965296 100644 --- a/pyramid/response.py +++ b/pyramid/response.py @@ -1,12 +1,12 @@ import venusian from webob import Response as _Response -from zope.interface import implements +from zope.interface import implementer from pyramid.interfaces import IResponse +@implementer(IResponse) class Response(_Response): - implements(IResponse) - + pass class response_adapter(object): """ Decorator activated via a :term:`scan` which treats the function diff --git a/pyramid/router.py b/pyramid/router.py index 746cf88cf..fb309eb03 100644 --- a/pyramid/router.py +++ b/pyramid/router.py @@ -1,4 +1,4 @@ -from zope.interface import implements +from zope.interface import implementer from zope.interface import providedBy from pyramid.interfaces import IDebugLogger @@ -23,8 +23,8 @@ from pyramid.traversal import DefaultRootFactory from pyramid.traversal import ResourceTreeTraverser from pyramid.tweens import excview_tween_factory +@implementer(IRouter) class Router(object): - implements(IRouter) debug_notfound = False debug_routematch = False diff --git a/pyramid/session.py b/pyramid/session.py index 633620716..b5e40c65d 100644 --- a/pyramid/session.py +++ b/pyramid/session.py @@ -6,7 +6,7 @@ import sys import time import os -from zope.interface import implements +from zope.interface import implementer from pyramid.compat import pickle from pyramid.interfaces import ISession @@ -84,9 +84,9 @@ def UnencryptedCookieSessionFactoryConfig( """ + @implementer(ISession) class UnencryptedCookieSessionFactory(dict): """ Dictionary-like session object """ - implements(ISession) # configuration parameters _cookie_name = cookie_name diff --git a/pyramid/testing.py b/pyramid/testing.py index 862b9d6b1..338eff9e9 100644 --- a/pyramid/testing.py +++ b/pyramid/testing.py @@ -3,7 +3,7 @@ import os from zope.deprecation import deprecated -from zope.interface import implements +from zope.interface import implementer from zope.interface import Interface from zope.interface import alsoProvides @@ -597,8 +597,8 @@ class DummyResource: DummyModel = DummyResource # b/w compat (forever) +@implementer(ISession) class DummySession(dict): - implements(ISession) created = None new = True def changed(self): @@ -628,6 +628,7 @@ class DummySession(dict): def get_csrf_token(self): return self.get('_csrft_', None) +@implementer(IRequest) class DummyRequest(DeprecatedRequestMethodsMixin, URLMethodsMixin, CallbackMethodsMixin): """ A DummyRequest object (incompletely) imitates a :term:`request` object. @@ -656,7 +657,6 @@ class DummyRequest(DeprecatedRequestMethodsMixin, URLMethodsMixin, a Request, use the :class:`pyramid.request.Request` class itself rather than this class while writing tests. """ - implements(IRequest) method = 'GET' application_url = 'http://example.com' host = 'example.com:80' diff --git a/pyramid/tests/test_config/__init__.py b/pyramid/tests/test_config/__init__.py index 2f9f516ae..5b40a8c09 100644 --- a/pyramid/tests/test_config/__init__.py +++ b/pyramid/tests/test_config/__init__.py @@ -1,6 +1,6 @@ # package -from zope.interface import implements +from zope.interface import implementer from zope.interface import Interface class IFactory(Interface): @@ -23,8 +23,8 @@ includeme = dummy_include class DummyContext: pass +@implementer(IFactory) class DummyFactory(object): - implements(IFactory) def __call__(self): """ """ diff --git a/pyramid/tests/test_config/test_adapters.py b/pyramid/tests/test_config/test_adapters.py index 29c099e0e..ff1ce52a1 100644 --- a/pyramid/tests/test_config/test_adapters.py +++ b/pyramid/tests/test_config/test_adapters.py @@ -9,12 +9,13 @@ class AdaptersConfiguratorMixinTests(unittest.TestCase): return config def test_add_subscriber_defaults(self): - from zope.interface import implements + from zope.interface import implementer from zope.interface import Interface class IEvent(Interface): pass + @implementer(IEvent) class Event: - implements(IEvent) + pass L = [] def subscriber(event): L.append(event) @@ -28,12 +29,13 @@ class AdaptersConfiguratorMixinTests(unittest.TestCase): self.assertEqual(len(L), 2) def test_add_subscriber_iface_specified(self): - from zope.interface import implements + from zope.interface import implementer from zope.interface import Interface class IEvent(Interface): pass + @implementer(IEvent) class Event: - implements(IEvent) + pass L = [] def subscriber(event): L.append(event) @@ -59,13 +61,13 @@ class AdaptersConfiguratorMixinTests(unittest.TestCase): self.assertEqual(handler.required, (INewRequest,)) def test_add_object_event_subscriber(self): - from zope.interface import implements + from zope.interface import implementer from zope.interface import Interface class IEvent(Interface): pass + @implementer(IEvent) class Event: object = 'foo' - implements(IEvent) event = Event() L = [] def subscriber(object, event): diff --git a/pyramid/tests/test_config/test_init.py b/pyramid/tests/test_config/test_init.py index 750cdb94f..6b5ea06b3 100644 --- a/pyramid/tests/test_config/test_init.py +++ b/pyramid/tests/test_config/test_init.py @@ -2,6 +2,8 @@ import unittest import os +from pyramid.compat import __pypy__ + from pyramid.tests.test_config import dummy_tween_factory from pyramid.tests.test_config import dummy_include from pyramid.tests.test_config import dummy_extend @@ -9,14 +11,8 @@ from pyramid.tests.test_config import dummy_extend2 from pyramid.tests.test_config import IDummy from pyramid.tests.test_config import DummyContext -try: - import __pypy__ -except: - __pypy__ = None - from pyramid.exceptions import ConfigurationExecutionError from pyramid.exceptions import ConfigurationConflictError -from pyramid.exceptions import ConfigurationError class ConfiguratorTests(unittest.TestCase): def _makeOne(self, *arg, **kw): @@ -309,10 +305,12 @@ class ConfiguratorTests(unittest.TestCase): def test__fix_registry_queryAdapterOrSelf(self): from zope.interface import Interface + from zope.interface import implementer class IFoo(Interface): pass + @implementer(IFoo) class Foo(object): - implements(IFoo) + pass class Bar(object): pass adaptation = () @@ -1118,9 +1116,9 @@ class TestConfiguratorDeprecatedFeatures(unittest.TestCase): def _registerRenderer(self, config, name='.txt'): from pyramid.interfaces import IRendererFactory from pyramid.interfaces import ITemplateRenderer - from zope.interface import implements + from zope.interface import implementer + @implementer(ITemplateRenderer) class Renderer: - implements(ITemplateRenderer) def __init__(self, info): self.__class__.info = info def __call__(self, *arg): @@ -1530,9 +1528,10 @@ class DummyThreadLocalManager(object): def pop(self): self.popped = True -from zope.interface import implements +from zope.interface import implementer +@implementer(IDummy) class DummyEvent: - implements(IDummy) + pass class DummyRegistry(object): def __init__(self, adaptation=None): @@ -1550,8 +1549,9 @@ class DummyRegistry(object): return self.adaptation from pyramid.interfaces import IResponse +@implementer(IResponse) class DummyResponse(object): - implements(IResponse) + pass from zope.interface import Interface class IOther(Interface): diff --git a/pyramid/tests/test_config/test_testing.py b/pyramid/tests/test_config/test_testing.py index 494a2b099..7f8c2c2b2 100644 --- a/pyramid/tests/test_config/test_testing.py +++ b/pyramid/tests/test_config/test_testing.py @@ -166,9 +166,10 @@ class TestingConfiguratorMixinTests(unittest.TestCase): renderer.assert_(bar=2) renderer.assert_(request=request) -from zope.interface import implements +from zope.interface import implementer +@implementer(IDummy) class DummyEvent: - implements(IDummy) + pass class DummyRequest: subpath = () diff --git a/pyramid/tests/test_config/test_views.py b/pyramid/tests/test_config/test_views.py index 84d53338e..c615c5a9e 100644 --- a/pyramid/tests/test_config/test_views.py +++ b/pyramid/tests/test_config/test_views.py @@ -38,9 +38,9 @@ class TestViewsConfigurationMixin(unittest.TestCase): def _registerRenderer(self, config, name='.txt'): from pyramid.interfaces import IRendererFactory from pyramid.interfaces import ITemplateRenderer - from zope.interface import implements + from zope.interface import implementer + @implementer(ITemplateRenderer) class Renderer: - implements(ITemplateRenderer) def __init__(self, info): self.__class__.info = info def __call__(self, *arg): @@ -3461,10 +3461,11 @@ class DummyRequest: class DummyContext: pass -from zope.interface import implements +from zope.interface import implementer from pyramid.interfaces import IResponse +@implementer(IResponse) class DummyResponse(object): - implements(IResponse) + pass class DummyAccept(object): def __init__(self, *matches): @@ -3510,10 +3511,10 @@ class DummyConfig: def action(self, discriminator, callable): callable() -from zope.interface import implements +from zope.interface import implementer from pyramid.interfaces import IMultiView +@implementer(IMultiView) class DummyMultiView: - implements(IMultiView) def __init__(self): self.views = [] self.name = 'name' diff --git a/pyramid/tests/test_location.py b/pyramid/tests/test_location.py index 3d30c9954..e1f47f4ab 100644 --- a/pyramid/tests/test_location.py +++ b/pyramid/tests/test_location.py @@ -34,7 +34,7 @@ class TestLineage(unittest.TestCase): self.assertEqual(result, [o1]) from pyramid.interfaces import ILocation -from zope.interface import implements +from zope.interface import implementer +@implementer(ILocation) class Location(object): - implements(ILocation) __name__ = __parent__ = None diff --git a/pyramid/tests/test_paster.py b/pyramid/tests/test_paster.py index cf551ed5c..f46aca49d 100644 --- a/pyramid/tests/test_paster.py +++ b/pyramid/tests/test_paster.py @@ -397,7 +397,7 @@ class TestPViewsCommand(unittest.TestCase): self.assertEqual(result, None) def test__find_view_no_match_multiview_registered(self): - from zope.interface import implements + from zope.interface import implementer from zope.interface import providedBy from pyramid.interfaces import IRequest from pyramid.interfaces import IViewClassifier @@ -405,8 +405,9 @@ class TestPViewsCommand(unittest.TestCase): from pyramid.traversal import DefaultRootFactory from pyramid.registry import Registry registry = Registry() + @implementer(IMultiView) class View1(object): - implements(IMultiView) + pass request = DummyRequest({'PATH_INFO':'/a'}) root = DefaultRootFactory(request) root_iface = providedBy(root) @@ -439,7 +440,7 @@ class TestPViewsCommand(unittest.TestCase): self.assertEqual(result, view1) def test__find_view_traversal_multiview(self): - from zope.interface import implements + from zope.interface import implementer from zope.interface import providedBy from pyramid.interfaces import IRequest from pyramid.interfaces import IViewClassifier @@ -447,8 +448,9 @@ class TestPViewsCommand(unittest.TestCase): from pyramid.traversal import DefaultRootFactory from pyramid.registry import Registry registry = Registry() + @implementer(IMultiView) class View1(object): - implements(IMultiView) + pass request = DummyRequest({'PATH_INFO':'/a'}) root = DefaultRootFactory(request) root_iface = providedBy(root) @@ -463,7 +465,7 @@ class TestPViewsCommand(unittest.TestCase): def test__find_view_route_no_multiview(self): from zope.interface import Interface - from zope.interface import implements + from zope.interface import implementer from pyramid.interfaces import IRouteRequest from pyramid.interfaces import IViewClassifier from pyramid.interfaces import IView @@ -478,8 +480,8 @@ class TestPViewsCommand(unittest.TestCase): (IViewClassifier, IMyRoute, IMyRoot), IView, '') registry.registerUtility(IMyRoute, IRouteRequest, name='a') + @implementer(IMyRoot) class Factory(object): - implements(IMyRoot) def __init__(self, request): pass routes = [DummyRoute('a', '/a', factory=Factory, matchdict={}), @@ -491,7 +493,7 @@ class TestPViewsCommand(unittest.TestCase): def test__find_view_route_multiview_no_view_registered(self): from zope.interface import Interface - from zope.interface import implements + from zope.interface import implementer from pyramid.interfaces import IRouteRequest from pyramid.interfaces import IMultiView from pyramid.interfaces import IRootFactory @@ -507,8 +509,8 @@ class TestPViewsCommand(unittest.TestCase): pass registry.registerUtility(IMyRoute1, IRouteRequest, name='a') registry.registerUtility(IMyRoute2, IRouteRequest, name='b') + @implementer(IMyRoot) class Factory(object): - implements(IMyRoot) def __init__(self, request): pass registry.registerUtility(Factory, IRootFactory) @@ -521,7 +523,7 @@ class TestPViewsCommand(unittest.TestCase): def test__find_view_route_multiview(self): from zope.interface import Interface - from zope.interface import implements + from zope.interface import implementer from pyramid.interfaces import IRouteRequest from pyramid.interfaces import IViewClassifier from pyramid.interfaces import IView @@ -545,8 +547,8 @@ class TestPViewsCommand(unittest.TestCase): IView, '') registry.registerUtility(IMyRoute1, IRouteRequest, name='a') registry.registerUtility(IMyRoute2, IRouteRequest, name='b') + @implementer(IMyRoot) class Factory(object): - implements(IMyRoot) def __init__(self, request): pass registry.registerUtility(Factory, IRootFactory) @@ -1042,10 +1044,10 @@ class DummyView(object): def __init__(self, **attrs): self.__request_attrs__ = attrs +from zope.interface import implementer +from pyramid.interfaces import IMultiView +@implementer(IMultiView) class DummyMultiView(object): - from zope.interface import implements - from pyramid.interfaces import IMultiView - implements(IMultiView) def __init__(self, *views, **attrs): self.views = [(None, view, None) for view in views] diff --git a/pyramid/tests/test_registry.py b/pyramid/tests/test_registry.py index 6a20eaa5d..c3104bd31 100644 --- a/pyramid/tests/test_registry.py +++ b/pyramid/tests/test_registry.py @@ -48,9 +48,11 @@ class DummyModule: __file__ = '' from zope.interface import Interface -from zope.interface import implements +from zope.interface import implementer class IDummyEvent(Interface): pass +@implementer(IDummyEvent) class DummyEvent(object): - implements(IDummyEvent) + pass + diff --git a/pyramid/tests/test_router.py b/pyramid/tests/test_router.py index ebb76f941..6a1cfd0d2 100644 --- a/pyramid/tests/test_router.py +++ b/pyramid/tests/test_router.py @@ -1165,10 +1165,10 @@ class DummyStartResponse: self.headers = headers from pyramid.interfaces import IResponse -from zope.interface import implements +from zope.interface import implementer +@implementer(IResponse) class DummyResponse(object): - implements(IResponse) headerlist = () app_iter = () environ = None diff --git a/pyramid/tests/test_testing.py b/pyramid/tests/test_testing.py index c131cc94b..919546a73 100644 --- a/pyramid/tests/test_testing.py +++ b/pyramid/tests/test_testing.py @@ -222,12 +222,12 @@ class Test_registerAdapter(TestBase): class Test_registerUtility(TestBase): def test_registerUtility(self): - from zope.interface import implements + from zope.interface import implementer from zope.interface import Interface class iface(Interface): pass + @implementer(iface) class impl: - implements(iface) def __call__(self): return 'foo' utility = impl() @@ -888,13 +888,15 @@ class TestDummySession(unittest.TestCase): from zope.interface import Interface -from zope.interface import implements +from zope.interface import implementer class IDummy(Interface): pass +@implementer(IDummy) class DummyEvent: - implements(IDummy) + pass + class DummyRequest: application_url = 'http://example.com' diff --git a/pyramid/tests/test_view.py b/pyramid/tests/test_view.py index 7f66a7563..29e468cd2 100644 --- a/pyramid/tests/test_view.py +++ b/pyramid/tests/test_view.py @@ -1,6 +1,8 @@ import unittest import sys +from zope.interface import implementer + from pyramid.testing import setUp from pyramid.testing import tearDown @@ -406,8 +408,9 @@ class TestViewConfigDecorator(unittest.TestCase): def test_call_with_renderer_IRendererInfo(self): import pyramid.tests from pyramid.interfaces import IRendererInfo + @implementer(IRendererInfo) class DummyRendererHelper(object): - implements(IRendererInfo) + pass renderer_helper = DummyRendererHelper() decorator = self._makeOne(renderer=renderer_helper) venusian = DummyVenusian() @@ -588,10 +591,9 @@ class DummyRequest: self.environ = environ from pyramid.interfaces import IResponse -from zope.interface import implements +@implementer(IResponse) class DummyResponse(object): - implements(IResponse) headerlist = () app_iter = () status = '200 OK' diff --git a/pyramid/traversal.py b/pyramid/traversal.py index 7fa80e6b3..de525e503 100644 --- a/pyramid/traversal.py +++ b/pyramid/traversal.py @@ -2,7 +2,7 @@ import sys import urllib import warnings -from zope.interface import implements +from zope.interface import implementer from zope.interface.interfaces import IInterface from repoze.lru import lru_cache @@ -12,7 +12,9 @@ from pyramid.interfaces import IRequestFactory from pyramid.interfaces import ITraverser from pyramid.interfaces import VH_ROOT_KEY +from pyramid.compat import native_ from pyramid.compat import text_ +from pyramid.compat import text_type from pyramid.encode import url_quote from pyramid.exceptions import URLDecodeError from pyramid.location import lineage @@ -529,22 +531,22 @@ def quote_path_segment(segment, safe=''): try: return _segment_cache[(segment, safe)] except KeyError: - if segment.__class__ is unicode: # isinstance slighly slower (~15%) + if segment.__class__ is text_type: # isinstance slighly slower (~15%) result = url_quote(segment.encode('utf-8'), safe) else: - result = url_quote(str(segment), safe) + result = url_quote(native_(segment), safe) # we don't need a lock to mutate _segment_cache, as the below # will generate exactly one Python bytecode (STORE_SUBSCR) _segment_cache[(segment, safe)] = result return result +@implementer(ITraverser) class ResourceTreeTraverser(object): """ A resource tree traverser that should be used (for speed) when every resource in the tree supplies a ``__name__`` and ``__parent__`` attribute (ie. every resource in the tree is :term:`location` aware) .""" - implements(ITraverser) VIEW_SELECTOR = '@@' @@ -650,10 +652,10 @@ class ResourceTreeTraverser(object): ModelGraphTraverser = ResourceTreeTraverser # b/w compat, not API, used in wild +@implementer(IContextURL) class TraversalContextURL(object): """ The IContextURL adapter used to generate URLs for a resource in a resource tree""" - implements(IContextURL) vroot_varname = VH_ROOT_KEY diff --git a/pyramid/urldispatch.py b/pyramid/urldispatch.py index 215f6a4a1..043203b79 100644 --- a/pyramid/urldispatch.py +++ b/pyramid/urldispatch.py @@ -1,6 +1,6 @@ import re import sys -from zope.interface import implements +from zope.interface import implementer from pyramid.interfaces import IRoutesMapper from pyramid.interfaces import IRoute @@ -13,8 +13,8 @@ from pyramid.traversal import quote_path_segment _marker = object() +@implementer(IRoute) class Route(object): - implements(IRoute) def __init__(self, name, pattern, factory=None, predicates=(), pregenerator=None): self.pattern = pattern @@ -25,8 +25,8 @@ class Route(object): self.predicates = predicates self.pregenerator = pregenerator +@implementer(IRoutesMapper) class RoutesMapper(object): - implements(IRoutesMapper) def __init__(self): self.routelist = [] self.routes = {} -- cgit v1.2.3