Skip to content

Commit

Permalink
Drop support for Python 2.4 and 2.5.
Browse files Browse the repository at this point in the history
Replace deprecated 'zope.component.adapts' usage with equivalent
'zope.component.adapter' decorator.

Replace deprecated 'zope.interface.classProvides' usage with equivalent
'zope.interface.provider' decorator.

Replace deprecated 'zope.interface.implementsOnly' usage with equivalent
'zope.interface.implementer_only'decorator.

Replace deprecated 'zope.interface.implements' usage with equivalent
'zope.interface.implementer' decorator.
  • Loading branch information
tseaver committed May 17, 2012
1 parent a5b97a0 commit 911efce
Show file tree
Hide file tree
Showing 13 changed files with 63 additions and 56 deletions.
18 changes: 16 additions & 2 deletions CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,22 @@
CHANGES
=======

3.12.1 (unreleased)
===================
4.0.0 (unreleased)
==================

- Replaced deprecated ``zope.component.adapts`` usage with equivalent
``zope.component.adapter`` decorator.

- Replaced deprecated ``zope.interface.classProvides`` usage with equivalent
``zope.interface.provider`` decorator.

- Replaced deprecated ``zope.interface.implementsOnly`` usage with equivalent
``zope.interface.implementer_only`` decorator.

- Replaced deprecated ``zope.interface.implements`` usage with equivalent
``zope.interface.implementer`` decorator.

- Dropped support for Python 2.4 and 2.5.


3.12.0 (2010-12-14)
Expand Down
5 changes: 4 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,17 @@
open('CHANGES.txt').read())

setup(name='zope.browserresource',
version = '3.12.1dev',
version = '4.0.0dev',
url='http://pypi.python.org/pypi/zope.browserresource/',
author='Zope Foundation and Contributors',
author_email='zope-dev@zope.org',
classifiers = ['Environment :: Web Environment',
'Intended Audience :: Developers',
'License :: OSI Approved :: Zope Public License',
'Programming Language :: Python',
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.6',
'Programming Language :: Python :: 2.7',
'Operating System :: OS Independent',
'Topic :: Internet :: WWW/HTTP',
'Framework :: Zope3',
Expand Down
10 changes: 4 additions & 6 deletions src/zope/browserresource/directory.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import os

from zope.component import queryUtility
from zope.interface import implements, classProvides
from zope.interface import implementer, provider
from zope.publisher.browser import BrowserView
from zope.publisher.interfaces import NotFound
from zope.publisher.interfaces.browser import IBrowserPublisher
Expand All @@ -48,10 +48,9 @@ def __init__(self, path, checker, name):
self.checker = checker
self.__name__ = name

@implementer(IBrowserPublisher)
class DirectoryResource(BrowserView, Resource):

implements(IBrowserPublisher)

default_factory = FileResourceFactory
directory_factory = None # this will be assigned later in the module
forbidden_names = ('.svn', )
Expand Down Expand Up @@ -102,11 +101,10 @@ def get(self, name, default=_marker):
return resource


@implementer(IResourceFactory)
@provider(IResourceFactoryFactory)
class DirectoryResourceFactory(object):

implements(IResourceFactory)
classProvides(IResourceFactoryFactory)

factoryClass = DirectoryResource

def __init__(self, path, checker, name):
Expand Down
17 changes: 7 additions & 10 deletions src/zope/browserresource/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
from email.Utils import formatdate, parsedate_tz, mktime_tz

from zope.contenttype import guess_content_type
from zope.interface import implements, classProvides
from zope.component import adapts, getMultiAdapter
from zope.interface import implementer, provider
from zope.component import adapter, getMultiAdapter
from zope.publisher.browser import BrowserView
from zope.publisher.interfaces import NotFound
from zope.publisher.interfaces.browser import IBrowserRequest
Expand Down Expand Up @@ -128,10 +128,9 @@ def __init__(self, path, name):
self.lmh = formatdate(self.lmt, usegmt=True)


@implementer(IFileResource, IBrowserPublisher)
class FileResource(BrowserView, Resource):

implements(IFileResource, IBrowserPublisher)

cacheTimeout = 86400

def publishTraverse(self, request, name):
Expand Down Expand Up @@ -286,11 +285,10 @@ def _testData(self):
return data


@adapter(IFileResource, IBrowserRequest)
@implementer(IETag)
class FileETag(object):

adapts(IFileResource, IBrowserRequest)
implements(IETag)

def __init__(self, context, request):
self.context = context
self.request = request
Expand All @@ -306,13 +304,12 @@ def setCacheControl(response, secs=86400):
response.setHeader('Expires', formatdate(t, usegmt=True))


@implementer(IResourceFactory)
@provider(IResourceFactoryFactory)
class FileResourceFactory(object):

resourceClass = FileResource

implements(IResourceFactory)
classProvides(IResourceFactoryFactory)

def __init__(self, path, checker, name):
self.__file = File(path, name)
self.__checker = checker
Expand Down
9 changes: 4 additions & 5 deletions src/zope/browserresource/i18nfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,16 @@
"""
from zope.i18n.interfaces import II18nAware
from zope.i18n.negotiator import negotiator
from zope.interface import implements, classProvides
from zope.interface import implementer, provider

from zope.browserresource.file import FileResource
from zope.browserresource.interfaces import IResourceFactory
from zope.browserresource.interfaces import IResourceFactoryFactory


@implementer(II18nAware)
class I18nFileResource(FileResource):

implements(II18nAware)

def __init__(self, data, request, defaultLanguage='en'):
"""Creates an internationalized file resource. data should be
a mapping from languages to File objects.
Expand Down Expand Up @@ -67,10 +66,10 @@ def _testData(self, language):
return data


@implementer(IResourceFactory)
@provider(IResourceFactoryFactory)
class I18nFileResourceFactory(object):

implements(IResourceFactory)
classProvides(IResourceFactoryFactory)

def __init__(self, data, defaultLanguage):
self.__data = data
Expand Down
7 changes: 3 additions & 4 deletions src/zope/browserresource/metaconfigure.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from zope.component.interface import provideInterface
from zope.component.zcml import handler
from zope.configuration.exceptions import ConfigurationError
from zope.interface import Interface, implements, classProvides
from zope.interface import Interface, implementer, provider
from zope.publisher.interfaces.browser import IBrowserRequest
from zope.publisher.interfaces.browser import IDefaultBrowserLayer
from zope.security.checker import CheckerPublic, NamesChecker, Checker
Expand All @@ -35,11 +35,10 @@
allowed_names = ('GET', 'HEAD', 'publishTraverse', 'browserDefault',
'request', '__call__')

@implementer(IResourceFactory)
@provider(IResourceFactoryFactory)
class ResourceFactoryWrapper(object):

implements(IResourceFactory)
classProvides(IResourceFactoryFactory)

def __init__(self, factory, checker, name):
self.__factory = factory
self.__checker = checker
Expand Down
12 changes: 5 additions & 7 deletions src/zope/browserresource/resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
"""Resource base class and AbsoluteURL adapter
"""
import zope.component.hooks
from zope.component import adapts, getMultiAdapter, queryMultiAdapter
from zope.interface import implements, implementsOnly
from zope.component import adapter, getMultiAdapter, queryMultiAdapter
from zope.interface import implementer, implementer_only
from zope.location import Location
from zope.publisher.interfaces.browser import IBrowserRequest
from zope.traversing.browser.interfaces import IAbsoluteURL
Expand All @@ -24,22 +24,20 @@
from zope.browserresource.interfaces import IResource


@implementer(IResource)
class Resource(Location):

implements(IResource)

def __init__(self, request):
self.request = request

def __call__(self):
return str(getMultiAdapter((self, self.request), IAbsoluteURL))


@implementer_only(IAbsoluteURL)
@adapter(IResource, IBrowserRequest)
class AbsoluteURL(zope.traversing.browser.absoluteurl.AbsoluteURL):

implementsOnly(IAbsoluteURL)
adapts(IResource, IBrowserRequest)

def __init__(self, context, request):
self.context = context
self.request = request
Expand Down
7 changes: 3 additions & 4 deletions src/zope/browserresource/resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,14 @@
"""Resource URL access
"""
from zope.component import queryAdapter
from zope.interface import implements
from zope.interface import implementer
from zope.location import locate
from zope.publisher.browser import BrowserView
from zope.publisher.interfaces import NotFound
from zope.publisher.interfaces.browser import IBrowserPublisher


@implementer(IBrowserPublisher)
class Resources(BrowserView):
"""A view that can be traversed further to access browser resources
Expand Down Expand Up @@ -90,9 +92,6 @@ class Resources(BrowserView):
'http://localhost/testresource'
"""

implements(IBrowserPublisher)

def publishTraverse(self, request, name):
'''See zope.publisher.interfaces.browser.IBrowserPublisher interface'''
resource = queryAdapter(request, name=name)
Expand Down
5 changes: 2 additions & 3 deletions src/zope/browserresource/tests/support.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,14 @@
import zope.component
import zope.component.hooks
import zope.component.interfaces
from zope.interface import implements
from zope.interface import implementer
from zope.traversing.interfaces import IContainmentRoot

import zope.browserresource.resource

@implementer(zope.component.interfaces.ISite, IContainmentRoot)
class Site:

implements(zope.component.interfaces.ISite, IContainmentRoot)

def getSiteManager(self):
return zope.component.getGlobalSiteManager()

Expand Down
4 changes: 2 additions & 2 deletions src/zope/browserresource/tests/test_directory.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
from zope.publisher.browser import TestRequest
from zope.security import proxy
from zope.security.checker import NamesChecker, ProxyFactory
from zope.interface import implements
from zope.interface import implementer
from zope.location.interfaces import IContained
from zope.traversing.browser.absoluteurl import AbsoluteURL
from zope.traversing.browser.interfaces import IAbsoluteURL
Expand All @@ -43,8 +43,8 @@
('get', '__getitem__', 'request', 'publishTraverse')
)

@implementer(IContained)
class Ob(object):
implements(IContained)
__parent__ = __name__ = None

ob = Ob()
Expand Down
12 changes: 6 additions & 6 deletions src/zope/browserresource/tests/test_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,17 @@
from zope.publisher.browser import TestRequest
from zope.publisher.interfaces.browser import IBrowserRequest
from zope.security.checker import NamesChecker
from zope.component import provideAdapter, adapts
from zope.interface import implements
from zope.component import provideAdapter, adapter
from zope.interface import implementer
from zope.interface.verify import verifyObject

from zope.browserresource.file import FileResourceFactory, FileETag
from zope.browserresource.interfaces import IFileResource, IETag


@adapter(IFileResource, IBrowserRequest)
@implementer(IETag)
class MyETag(object):
adapts(IFileResource, IBrowserRequest)
implements(IETag)

def __init__(self, context, request):
pass
Expand All @@ -46,9 +46,9 @@ def __call__(self, mtime, content):
return 'myetag'


@adapter(IFileResource, IBrowserRequest)
@implementer(IETag)
class NoETag(object):
adapts(IFileResource, IBrowserRequest)
implements(IETag)

def __init__(self, context, request):
pass
Expand Down
8 changes: 4 additions & 4 deletions src/zope/browserresource/tests/test_i18nfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@

from zope.publisher.interfaces import NotFound

from zope.interface import implements
from zope.component import provideAdapter, provideUtility, adapts
from zope.interface import implementer
from zope.component import provideAdapter, provideUtility, adapter
from zope.testing import cleanup

from zope.i18n.interfaces import IUserPreferredCharsets, IUserPreferredLanguages
Expand All @@ -42,9 +42,9 @@
test_directory = os.path.dirname(p.__file__)


@adapter(IFileResource, IBrowserRequest)
@implementer(IETag)
class MyETag(object):
adapts(IFileResource, IBrowserRequest)
implements(IETag)

def __init__(self, context, request):
pass
Expand Down
5 changes: 3 additions & 2 deletions src/zope/browserresource/tests/test_icondirective.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from zope import component
from zope.configuration.exceptions import ConfigurationError
from zope.configuration.xmlconfig import xmlconfig, XMLConfig
from zope.interface import implements
from zope.interface import implementer
from zope.publisher.browser import TestRequest
from zope.security.checker import ProxyFactory, CheckerPublic
from zope.security.interfaces import Forbidden
Expand All @@ -47,8 +47,9 @@

request = TestRequest()

@implementer(IC)
class Ob(object):
implements(IC)
pass

ob = Ob()
request._vh_root = support.site
Expand Down

0 comments on commit 911efce

Please sign in to comment.