Commit df082f19 authored by Tres Seaver's avatar Tres Seaver

Drop support for Python 2.4 and 2.5.

Replace deprecated 'zope.component.adapts' usage with equivalent
'zope.component.adapter' decorator.

Replace deprecated 'zope.interface.implements' usage with equivalent
'zope.interface.implementer' decorator.
parent 6d8039d9
...@@ -2,9 +2,17 @@ ...@@ -2,9 +2,17 @@
CHANGES 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.implements`` usage with equivalent
``zope.interface.implementer`` decorator.
- Dropped support for Python 2.4 and 2.5.
- Send ``IContainerModifiedEvent`` *after* the container is modified - Send ``IContainerModifiedEvent`` *after* the container is modified
(LP#705600). (LP#705600).
......
...@@ -25,7 +25,7 @@ def read(*rnames): ...@@ -25,7 +25,7 @@ def read(*rnames):
return open(os.path.join(os.path.dirname(__file__), *rnames)).read() return open(os.path.join(os.path.dirname(__file__), *rnames)).read()
setup(name='zope.container', setup(name='zope.container',
version = '3.12.1dev', version = '4.0.0dev',
author='Zope Foundation and Contributors', author='Zope Foundation and Contributors',
author_email='zope-dev@zope.org', author_email='zope-dev@zope.org',
description='Zope Container', description='Zope Container',
...@@ -45,11 +45,14 @@ setup(name='zope.container', ...@@ -45,11 +45,14 @@ setup(name='zope.container',
'Intended Audience :: Developers', 'Intended Audience :: Developers',
'License :: OSI Approved :: Zope Public License', 'License :: OSI Approved :: Zope Public License',
'Programming Language :: Python', 'Programming Language :: Python',
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.6',
'Programming Language :: Python :: 2.7',
'Natural Language :: English', 'Natural Language :: English',
'Operating System :: OS Independent', 'Operating System :: OS Independent',
'Topic :: Internet :: WWW/HTTP', 'Topic :: Internet :: WWW/HTTP',
'Framework :: Zope3'], 'Framework :: Zope3',
],
url='http://pypi.python.org/pypi/zope.container', url='http://pypi.python.org/pypi/zope.container',
license='ZPL 2.1', license='ZPL 2.1',
packages=find_packages('src'), packages=find_packages('src'),
......
...@@ -21,7 +21,7 @@ from BTrees.Length import Length ...@@ -21,7 +21,7 @@ from BTrees.Length import Length
from zope.container.interfaces import IBTreeContainer from zope.container.interfaces import IBTreeContainer
from zope.container.contained import Contained, setitem, uncontained from zope.container.contained import Contained, setitem, uncontained
from zope.interface import implements from zope.interface import implementer
class Lazy(object): class Lazy(object):
...@@ -44,10 +44,9 @@ class Lazy(object): ...@@ -44,10 +44,9 @@ class Lazy(object):
return value return value
@implementer(IBTreeContainer)
class BTreeContainer(Contained, Persistent): class BTreeContainer(Contained, Persistent):
implements(IBTreeContainer)
def __init__(self): def __init__(self):
# We keep the previous attribute to store the data # We keep the previous attribute to store the data
# for backward compatibility # for backward compatibility
......
...@@ -34,8 +34,8 @@ ...@@ -34,8 +34,8 @@
... __setitem__.precondition = preNoZ ... __setitem__.precondition = preNoZ
>>> from zope.container.interfaces import IContainer >>> from zope.container.interfaces import IContainer
>>> class C1(object): >>> @zope.interface.implementer(I1, IContainer)
... zope.interface.implements(I1, IContainer) ... class C1(object):
... def __repr__(self): ... def __repr__(self):
... return 'C1' ... return 'C1'
...@@ -66,8 +66,9 @@ ...@@ -66,8 +66,9 @@
>>> class I2(zope.interface.Interface): >>> class I2(zope.interface.Interface):
... __parent__ = zope.schema.Field(constraint = con1) ... __parent__ = zope.schema.Field(constraint = con1)
>>> class O(object): >>> @zope.interface.implementer(I2)
... zope.interface.implements(I2) ... class O(object):
... pass
If the constraint isn't satisfied, we'll get a validation error when we If the constraint isn't satisfied, we'll get a validation error when we
check whether the object can be added: check whether the object can be added:
...@@ -90,8 +91,9 @@ ...@@ -90,8 +91,9 @@
>>> class I2(zope.interface.Interface): >>> class I2(zope.interface.Interface):
... __parent__ = zope.schema.Field(constraint = con1) ... __parent__ = zope.schema.Field(constraint = con1)
>>> class O(object): >>> @zope.interface.implementer(I2)
... zope.interface.implements(I2) ... class O(object):
... pass
>>> checkObject(c1, "bob", O()) >>> checkObject(c1, "bob", O())
Traceback (most recent call last): Traceback (most recent call last):
...@@ -279,6 +281,7 @@ class _TypesBased(object): ...@@ -279,6 +281,7 @@ class _TypesBased(object):
self.types = types self.types = types
@zope.interface.implementer(IItemTypePrecondition)
class ItemTypePrecondition(_TypesBased): class ItemTypePrecondition(_TypesBased):
"""Specify a `__setitem__` precondition that restricts item types """Specify a `__setitem__` precondition that restricts item types
...@@ -326,7 +329,6 @@ class ItemTypePrecondition(_TypesBased): ...@@ -326,7 +329,6 @@ class ItemTypePrecondition(_TypesBased):
""" """
zope.interface.implements(IItemTypePrecondition)
def __call__(self, container, name, object): def __call__(self, container, name, object):
for iface in self.types: for iface in self.types:
...@@ -399,6 +401,7 @@ class IContainerTypesConstraint(zope.interface.Interface): ...@@ -399,6 +401,7 @@ class IContainerTypesConstraint(zope.interface.Interface):
""" """
@zope.interface.implementer(IContainerTypesConstraint)
class ContainerTypesConstraint(_TypesBased): class ContainerTypesConstraint(_TypesBased):
"""Constrain a container to be one of a number of types """Constrain a container to be one of a number of types
...@@ -423,9 +426,6 @@ class ContainerTypesConstraint(_TypesBased): ...@@ -423,9 +426,6 @@ class ContainerTypesConstraint(_TypesBased):
True True
""" """
zope.interface.implements(IContainerTypesConstraint)
def __call__(self, object): def __call__(self, object):
for iface in self.types: for iface in self.types:
if iface.providedBy(object): if iface.providedBy(object):
......
...@@ -31,11 +31,13 @@ folders: ...@@ -31,11 +31,13 @@ folders:
>>> from zope import interface >>> from zope import interface
>>> class Buddy: >>> @interface.implementer(IBuddy)
... interface.implements(IBuddy) ... class Buddy:
... pass
>>> class BuddyFolder: >>> @interface.implementer(IBuddyFolder)
... interface.implements(IBuddyFolder) ... class BuddyFolder:
... pass
>>> from zope.container.constraints import checkObject, checkFactory >>> from zope.container.constraints import checkObject, checkFactory
>>> from zope.component.factory import Factory >>> from zope.component.factory import Factory
...@@ -46,11 +48,13 @@ folders: ...@@ -46,11 +48,13 @@ folders:
If we try to use other containers or folders, we'll get errors: If we try to use other containers or folders, we'll get errors:
>>> class Container: >>> @interface.implementer(IContainer)
... interface.implements(IContainer) ... class Container:
... pass
>>> class Contained: >>> @interface.implementer(IContained)
... interface.implements(IContained) ... class Contained:
... pass
>>> checkObject(Container(), 'x', Buddy()) >>> checkObject(Container(), 'x', Buddy())
... # doctest: +ELLIPSIS ... # doctest: +ELLIPSIS
...@@ -77,11 +81,13 @@ could have defined these in the opposite order: ...@@ -77,11 +81,13 @@ could have defined these in the opposite order:
>>> class IContacts(IContainer): >>> class IContacts(IContainer):
... contains(IContact) ... contains(IContact)
>>> class Contact: >>> @interface.implementer(IContact)
... interface.implements(IContact) ... class Contact:
... pass
>>> class Contacts: >>> @interface.implementer(IContacts)
... interface.implements(IContacts) ... class Contacts:
... pass
>>> checkObject(Contacts(), 'x', Contact()) >>> checkObject(Contacts(), 'x', Contact())
......
...@@ -44,17 +44,17 @@ except ImportError: ...@@ -44,17 +44,17 @@ except ImportError:
from zope.broken.interfaces import IBroken from zope.broken.interfaces import IBroken
@zope.interface.implementer(IContained)
class Contained(object): class Contained(object):
"""Stupid mix-in that defines `__parent__` and `__name__` attributes""" """Stupid mix-in that defines `__parent__` and `__name__` attributes"""
zope.interface.implements(IContained)
__parent__ = __name__ = None __parent__ = __name__ = None
@zope.interface.implementer(IContainerModifiedEvent)
class ContainerModifiedEvent(ObjectModifiedEvent): class ContainerModifiedEvent(ObjectModifiedEvent):
"""The container has been modified.""" """The container has been modified."""
zope.interface.implements(IContainerModifiedEvent)
def dispatchToSublocations(object, event): def dispatchToSublocations(object, event):
...@@ -67,8 +67,8 @@ def dispatchToSublocations(object, event): ...@@ -67,8 +67,8 @@ def dispatchToSublocations(object, event):
Suppose, for example, that we define some location objects. Suppose, for example, that we define some location objects.
>>> class L(object): >>> @zope.interface.implementer(ILocation)
... zope.interface.implements(ILocation) ... class L(object):
... def __init__(self, name): ... def __init__(self, name):
... self.__name__ = name ... self.__name__ = name
... self.__parent__ = None ... self.__parent__ = None
...@@ -76,8 +76,8 @@ def dispatchToSublocations(object, event): ...@@ -76,8 +76,8 @@ def dispatchToSublocations(object, event):
... return '%s(%s)' % ( ... return '%s(%s)' % (
... self.__class__.__name__, str(self.__name__)) ... self.__class__.__name__, str(self.__name__))
>>> class C(L): >>> @zope.interface.implementer(ISublocations)
... zope.interface.implements(ISublocations) ... class C(L):
... def __init__(self, name, *subs): ... def __init__(self, name, *subs):
... L.__init__(self, name) ... L.__init__(self, name)
... self.subs = subs ... self.subs = subs
...@@ -342,8 +342,8 @@ def setitem(container, setitemf, name, object): ...@@ -342,8 +342,8 @@ def setitem(container, setitemf, name, object):
>>> class IItem(zope.interface.Interface): >>> class IItem(zope.interface.Interface):
... pass ... pass
>>> class Item(Contained): >>> @zope.interface.implementer(IItem)
... zope.interface.implements(IItem) ... class Item(Contained):
... def setAdded(self, event): ... def setAdded(self, event):
... self.added = event ... self.added = event
... def setMoved(self, event): ... def setMoved(self, event):
...@@ -683,10 +683,9 @@ def uncontained(object, container, name=None): ...@@ -683,10 +683,9 @@ def uncontained(object, container, name=None):
object.__name__ = None object.__name__ = None
notifyContainerModified(container) notifyContainerModified(container)
@zope.interface.implementer(INameChooser)
class NameChooser(object): class NameChooser(object):
zope.interface.implements(INameChooser)
def __init__(self, context): def __init__(self, context):
self.context = context self.context = context
...@@ -730,9 +729,9 @@ class NameChooser(object): ...@@ -730,9 +729,9 @@ class NameChooser(object):
to a container: to a container:
>>> from zope.container.interfaces import IContainer >>> from zope.container.interfaces import IContainer
>>> class ReservedNames(object): >>> @zope.component.adapter(IContainer)
... zope.component.adapts(IContainer) ... @zope.interface.implementer(IReservedNames)
... zope.interface.implements(IReservedNames) ... class ReservedNames(object):
... ...
... def __init__(self, context): ... def __init__(self, context):
... self.reservedNames = set(('reserved', 'other')) ... self.reservedNames = set(('reserved', 'other'))
...@@ -855,15 +854,18 @@ class DecoratorSpecificationDescriptor( ...@@ -855,15 +854,18 @@ class DecoratorSpecificationDescriptor(
>>> class I4(Interface): >>> class I4(Interface):
... pass ... pass
>>> class D1(ContainedProxy): >>> @implementer(I1)
... implements(I1) ... class D1(ContainedProxy):
... pass
>>> class D2(ContainedProxy): >>> @implementer(I2)
... implements(I2) ... class D2(ContainedProxy):
... pass
>>> class X: >>> @implementer(I3)
... implements(I3) ... class X:
... pass
>>> x = X() >>> x = X()
>>> directlyProvides(x, I4) >>> directlyProvides(x, I4)
...@@ -923,6 +925,7 @@ class ContainedProxyClassProvides(zope.interface.declarations.ClassProvides): ...@@ -923,6 +925,7 @@ class ContainedProxyClassProvides(zope.interface.declarations.ClassProvides):
inst = getProxiedObject(inst) inst = getProxiedObject(inst)
del inst.__provides__ del inst.__provides__
@zope.interface.implementer(IContained)
class ContainedProxy(ContainedProxyBase): class ContainedProxy(ContainedProxyBase):
# Prevent proxies from having their own instance dictionaries: # Prevent proxies from having their own instance dictionaries:
...@@ -930,8 +933,6 @@ class ContainedProxy(ContainedProxyBase): ...@@ -930,8 +933,6 @@ class ContainedProxy(ContainedProxyBase):
__safe_for_unpickling__ = True __safe_for_unpickling__ = True
zope.interface.implements(IContained)
__providedBy__ = DecoratorSpecificationDescriptor() __providedBy__ = DecoratorSpecificationDescriptor()
__Security_checker__ = DecoratedSecurityCheckerDescriptor() __Security_checker__ = DecoratedSecurityCheckerDescriptor()
......
...@@ -23,7 +23,7 @@ providing a file-system representation for containers: ...@@ -23,7 +23,7 @@ providing a file-system representation for containers:
""" """
__docformat__ = 'restructuredtext' __docformat__ = 'restructuredtext'
from zope.interface import implements from zope.interface import implementer
from zope.component.interfaces import ISite from zope.component.interfaces import ISite
from zope.security.proxy import removeSecurityProxy from zope.security.proxy import removeSecurityProxy
...@@ -40,15 +40,13 @@ def noop(container): ...@@ -40,15 +40,13 @@ def noop(container):
return container return container
@implementer(zope.filerepresentation.interfaces.IDirectoryFactory)
class Cloner(object): class Cloner(object):
"""`IContainer` to `IDirectoryFactory` adapter that clones """`IContainer` to `IDirectoryFactory` adapter that clones
This adapter provides a factory that creates a new empty container This adapter provides a factory that creates a new empty container
of the same class as it's context. of the same class as it's context.
""" """
implements(zope.filerepresentation.interfaces.IDirectoryFactory)
def __init__(self, context): def __init__(self, context):
self.context = context self.context = context
......
...@@ -15,14 +15,13 @@ ...@@ -15,14 +15,13 @@
""" """
__docformat__ = 'restructuredtext' __docformat__ = 'restructuredtext'
from zope.interface import implements from zope.interface import implementer
from interfaces import IFind, IIdFindFilter, IObjectFindFilter from interfaces import IFind, IIdFindFilter, IObjectFindFilter
from interfaces import IReadContainer from interfaces import IReadContainer
@implementer(IFind)
class FindAdapter(object): class FindAdapter(object):
implements(IFind)
__used_for__ = IReadContainer __used_for__ = IReadContainer
def __init__(self, context): def __init__(self, context):
...@@ -62,10 +61,9 @@ def _find_helper(id, object, container, id_filters, object_filters, result): ...@@ -62,10 +61,9 @@ def _find_helper(id, object, container, id_filters, object_filters, result):
for id, object in container.items(): for id, object in container.items():
_find_helper(id, object, container, id_filters, object_filters, result) _find_helper(id, object, container, id_filters, object_filters, result)
@implementer(IIdFindFilter)
class SimpleIdFindFilter(object): class SimpleIdFindFilter(object):
implements(IIdFindFilter)
def __init__(self, ids): def __init__(self, ids):
self._ids = ids self._ids = ids
...@@ -73,9 +71,9 @@ class SimpleIdFindFilter(object): ...@@ -73,9 +71,9 @@ class SimpleIdFindFilter(object):
'See INameFindFilter' 'See INameFindFilter'
return id in self._ids return id in self._ids
@implementer(IObjectFindFilter)
class SimpleInterfacesFindFilter(object): class SimpleInterfacesFindFilter(object):
"""Filter objects on the provided interfaces""" """Filter objects on the provided interfaces"""
implements(IObjectFindFilter)
def __init__(self, *interfaces): def __init__(self, *interfaces):
self.interfaces = interfaces self.interfaces = interfaces
......
...@@ -19,7 +19,7 @@ from BTrees.OOBTree import OOBTree ...@@ -19,7 +19,7 @@ from BTrees.OOBTree import OOBTree
from persistent import Persistent from persistent import Persistent
from zope.container.interfaces import IContainer, IContentContainer from zope.container.interfaces import IContainer, IContentContainer
from zope.container.contained import Contained, setitem, uncontained from zope.container.contained import Contained, setitem, uncontained
from zope.interface import implements, directlyProvides from zope.interface import implementer
# XXX This container implementation is really only used by # XXX This container implementation is really only used by
# zope.site.folder.Folder. Please do not use it. # zope.site.folder.Folder. Please do not use it.
...@@ -27,10 +27,10 @@ from zope.interface import implements, directlyProvides ...@@ -27,10 +27,10 @@ from zope.interface import implements, directlyProvides
# XXX Check whether this IContainer implementation cannot really # XXX Check whether this IContainer implementation cannot really
# be replaced by the BTreeContainer. # be replaced by the BTreeContainer.
@implementer(IContentContainer)
class Folder(Persistent, Contained): class Folder(Persistent, Contained):
"""The standard Zope Folder implementation.""" """The standard Zope Folder implementation."""
implements(IContentContainer)
def __init__(self): def __init__(self):
self.data = OOBTree() self.data = OOBTree()
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
__docformat__ = 'restructuredtext' __docformat__ = 'restructuredtext'
from zope.container.interfaces import IOrderedContainer from zope.container.interfaces import IOrderedContainer
from zope.interface import implements from zope.interface import implementer
from persistent import Persistent from persistent import Persistent
from persistent.dict import PersistentDict from persistent.dict import PersistentDict
from persistent.list import PersistentList from persistent.list import PersistentList
...@@ -24,6 +24,7 @@ from types import StringTypes, TupleType, ListType ...@@ -24,6 +24,7 @@ from types import StringTypes, TupleType, ListType
from zope.container.contained import Contained, setitem, uncontained from zope.container.contained import Contained, setitem, uncontained
from zope.container.contained import notifyContainerModified from zope.container.contained import notifyContainerModified
@implementer(IOrderedContainer)
class OrderedContainer(Persistent, Contained): class OrderedContainer(Persistent, Contained):
""" `OrderedContainer` maintains entries' order as added and moved. """ `OrderedContainer` maintains entries' order as added and moved.
...@@ -33,9 +34,6 @@ class OrderedContainer(Persistent, Contained): ...@@ -33,9 +34,6 @@ class OrderedContainer(Persistent, Contained):
>>> len(oc) >>> len(oc)
0 0
""" """
implements(IOrderedContainer)
def __init__(self): def __init__(self):
self._data = PersistentDict() self._data = PersistentDict()
......
...@@ -21,17 +21,17 @@ need a very different implementation. ...@@ -21,17 +21,17 @@ need a very different implementation.
__docformat__ = 'restructuredtext' __docformat__ = 'restructuredtext'
from zope.container.interfaces import IContainer from zope.container.interfaces import IContainer
from zope.interface import implements from zope.interface import implementer
from zope.container.contained import Contained, setitem, uncontained from zope.container.contained import Contained, setitem, uncontained
@implementer(IContainer)
class SampleContainer(Contained): class SampleContainer(Contained):
"""Sample container implementation suitable for testing. """Sample container implementation suitable for testing.
It is not suitable, directly as a base class unless the subclass It is not suitable, directly as a base class unless the subclass
overrides `_newContainerData` to return a persistent mapping object. overrides `_newContainerData` to return a persistent mapping object.
""" """
implements(IContainer)
def __init__(self): def __init__(self):
self.__data = self._newContainerData() self.__data = self._newContainerData()
......
...@@ -18,12 +18,11 @@ __docformat__ = 'restructuredtext' ...@@ -18,12 +18,11 @@ __docformat__ = 'restructuredtext'
from zope.container.i18n import ZopeMessageFactory as _ from zope.container.i18n import ZopeMessageFactory as _
from zope.size.interfaces import ISized from zope.size.interfaces import ISized
from zope.interface import implements from zope.interface import implementer
@implementer(ISized)
class ContainerSized(object): class ContainerSized(object):
implements(ISized)
def __init__(self, container): def __init__(self, container):
self._container = container self._container = container
......
...@@ -97,8 +97,9 @@ def test_declarations_on_ContainedProxy(): ...@@ -97,8 +97,9 @@ def test_declarations_on_ContainedProxy():
>>> class I1(zope.interface.Interface): >>> class I1(zope.interface.Interface):
... pass ... pass
>>> class C(object): >>> @zope.interface.implementer(I1)
... zope.interface.implements(I1) ... class C(object):
... pass
>>> c = C() >>> c = C()
>>> p = ContainedProxy(c) >>> p = ContainedProxy(c)
...@@ -350,9 +351,9 @@ class TestNameChooser(unittest.TestCase): ...@@ -350,9 +351,9 @@ class TestNameChooser(unittest.TestCase):
self.assertEqual(True, checkName(u'r\xe9served', object())) self.assertEqual(True, checkName(u'r\xe9served', object()))
# reserved names # reserved names
@zope.component.adapter(IContainer)
@zope.interface.implementer(IReservedNames)
class ReservedNames(object): class ReservedNames(object):
zope.component.adapts(IContainer)
zope.interface.implements(IReservedNames)
def __init__(self, context): def __init__(self, context):
self.reservedNames = set(('reserved', 'other')) self.reservedNames = set(('reserved', 'other'))
zope.component.getSiteManager().registerAdapter(ReservedNames) zope.component.getSiteManager().registerAdapter(ReservedNames)
......
...@@ -15,16 +15,15 @@ ...@@ -15,16 +15,15 @@
""" """
import unittest import unittest
from zope.testing.cleanup import CleanUp from zope.testing.cleanup import CleanUp
from zope.interface import implements from zope.interface import implementer
from zope.traversing.interfaces import TraversalError from zope.traversing.interfaces import TraversalError
from zope.container.traversal import ContainerTraversable from zope.container.traversal import ContainerTraversable
from zope.container.interfaces import IContainer from zope.container.interfaces import IContainer
@implementer(IContainer)
class Container(object): class Container(object):
implements(IContainer)
def __init__(self, attrs={}, objs={}): def __init__(self, attrs={}, objs={}):
for attr,value in attrs.iteritems(): for attr,value in attrs.iteritems():
setattr(self, attr, value) setattr(self, attr, value)
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
"""Container Traverser Tests """Container Traverser Tests
""" """
import unittest import unittest
from zope.interface import Interface, implements from zope.interface import Interface, implementer
from zope import component from zope import component
from zope.publisher.interfaces import NotFound, IDefaultViewName from zope.publisher.interfaces import NotFound, IDefaultViewName
from zope.publisher.browser import TestRequest from zope.publisher.browser import TestRequest
...@@ -24,8 +24,8 @@ from zope.container.traversal import ContainerTraverser ...@@ -24,8 +24,8 @@ from zope.container.traversal import ContainerTraverser
from zope.container.interfaces import IReadContainer from zope.container.interfaces import IReadContainer
from zope.container import testing from zope.container import testing
@implementer(IReadContainer)
class TestContainer(object): class TestContainer(object):
implements(IReadContainer)
def __init__(self, **kw): def __init__(self, **kw):
for name, value in kw.items(): for name, value in kw.items():
......
import unittest import unittest
from zope.configuration.xmlconfig import XMLConfig from zope.configuration.xmlconfig import XMLConfig
from zope.interface import implements from zope.interface import implementer
from zope.publisher.browser import TestRequest from zope.publisher.browser import TestRequest
from zope.publisher.interfaces.browser import IBrowserPublisher from zope.publisher.interfaces.browser import IBrowserPublisher
...@@ -22,8 +22,9 @@ class ZCMLDependencies(ContainerPlacelessSetup, unittest.TestCase): ...@@ -22,8 +22,9 @@ class ZCMLDependencies(ContainerPlacelessSetup, unittest.TestCase):
request = TestRequest() request = TestRequest()
@implementer(IItemContainer)
class SampleItemContainer(object): class SampleItemContainer(object):
implements(IItemContainer) pass
sampleitemcontainer = SampleItemContainer() sampleitemcontainer = SampleItemContainer()
res = zope.component.getMultiAdapter( res = zope.component.getMultiAdapter(
...@@ -31,8 +32,9 @@ class ZCMLDependencies(ContainerPlacelessSetup, unittest.TestCase): ...@@ -31,8 +32,9 @@ class ZCMLDependencies(ContainerPlacelessSetup, unittest.TestCase):
self.failUnless(isinstance(res, ItemTraverser)) self.failUnless(isinstance(res, ItemTraverser))
self.failUnless(res.context is sampleitemcontainer) self.failUnless(res.context is sampleitemcontainer)
@implementer(ISimpleReadContainer)
class SampleSimpleReadContainer(object): class SampleSimpleReadContainer(object):
implements(ISimpleReadContainer) pass
samplesimplereadcontainer = SampleSimpleReadContainer() samplesimplereadcontainer = SampleSimpleReadContainer()
res = zope.component.getMultiAdapter( res = zope.component.getMultiAdapter(
......
...@@ -18,10 +18,10 @@ from zope.container.interfaces import IReadContainer ...@@ -18,10 +18,10 @@ from zope.container.interfaces import IReadContainer
from zope.container.interfaces import IObjectFindFilter from zope.container.interfaces import IObjectFindFilter
from zope.container.find import FindAdapter, SimpleIdFindFilter from zope.container.find import FindAdapter, SimpleIdFindFilter
from zope.container.find import SimpleInterfacesFindFilter from zope.container.find import SimpleInterfacesFindFilter
from zope.interface import implements, Interface, directlyProvides from zope.interface import implementer, Interface, directlyProvides
@implementer(IReadContainer)
class FakeContainer(object): class FakeContainer(object):
implements(IReadContainer)
def __init__(self, id, objects): def __init__(self, id, objects):
self._id = id self._id = id
...@@ -67,8 +67,8 @@ class FakeInterfaceBar(Interface): ...@@ -67,8 +67,8 @@ class FakeInterfaceBar(Interface):
class FakeInterfaceSpam(Interface): class FakeInterfaceSpam(Interface):
"""Test interface Spam""" """Test interface Spam"""
@implementer(IObjectFindFilter)
class TestObjectFindFilter(object): class TestObjectFindFilter(object):
implements(IObjectFindFilter)
def __init__(self, count): def __init__(self, count):
self._count = count self._count = count
......
...@@ -15,14 +15,13 @@ ...@@ -15,14 +15,13 @@
""" """
import unittest import unittest
from zope.interface import implements from zope.interface import implementer
from zope.size.interfaces import ISized from zope.size.interfaces import ISized
from zope.container.interfaces import IContainer from zope.container.interfaces import IContainer
@implementer(IContainer)
class DummyContainer(object): class DummyContainer(object):
implements(IContainer)
def __init__(self, numitems): def __init__(self, numitems):
self._numitems = numitems self._numitems = numitems
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
""" """
__docformat__ = 'restructuredtext' __docformat__ = 'restructuredtext'
from zope.interface import implements, providedBy from zope.interface import implementer, providedBy
from zope.component import queryMultiAdapter, getSiteManager from zope.component import queryMultiAdapter, getSiteManager
from zope.component import ComponentLookupError from zope.component import ComponentLookupError
from zope.traversing.interfaces import TraversalError, ITraversable from zope.traversing.interfaces import TraversalError, ITraversable
...@@ -29,10 +29,10 @@ from zope.container.interfaces import IReadContainer ...@@ -29,10 +29,10 @@ from zope.container.interfaces import IReadContainer
# Note that the next two classes are included here because they # Note that the next two classes are included here because they
# can be used for multiple view types. # can be used for multiple view types.
@implementer(IBrowserPublisher, IXMLRPCPublisher)
class ContainerTraverser(object): class ContainerTraverser(object):
"""A traverser that knows how to look up objects by name in a container.""" """A traverser that knows how to look up objects by name in a container."""
implements(IBrowserPublisher, IXMLRPCPublisher)
__used_for__ = ISimpleReadContainer __used_for__ = ISimpleReadContainer
def __init__(self, container, request): def __init__(self, container, request):
...@@ -84,10 +84,10 @@ class ItemTraverser(ContainerTraverser): ...@@ -84,10 +84,10 @@ class ItemTraverser(ContainerTraverser):
_marker = object() _marker = object()
@implementer(ITraversable)
class ContainerTraversable(object): class ContainerTraversable(object):
"""Traverses containers via `getattr` and `get`.""" """Traverses containers via `getattr` and `get`."""
implements(ITraversable)
__used_for__ = IReadContainer __used_for__ = IReadContainer
def __init__(self, container): def __init__(self, container):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment