diff --git a/CHANGES.rst b/CHANGES.rst index 94d1aee9..3d01664e 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -14,7 +14,8 @@ New features: Bug fixes: -- *add item here* +- Use zope.interface decorator. + [gforcada] 1.11.0 (2016-05-15) diff --git a/Products/Archetypes/ArchetypeTool.py b/Products/Archetypes/ArchetypeTool.py index 90656f1c..01ee0497 100644 --- a/Products/Archetypes/ArchetypeTool.py +++ b/Products/Archetypes/ArchetypeTool.py @@ -4,7 +4,7 @@ from DateTime import DateTime from StringIO import StringIO -from zope.interface import implements +from zope.interface import implementer from Products.Archetypes import PloneMessageFactory as _ from Products.Archetypes.interfaces import IArchetypeTool @@ -438,6 +438,7 @@ def __call__(self): last_load = DateTime() +@implementer(IArchetypeTool) class ArchetypeTool(UniqueObject, ActionProviderBase, SQLStorageConfig, Folder): """Archetypes tool, manage aspects of Archetype instances. @@ -445,8 +446,6 @@ class ArchetypeTool(UniqueObject, ActionProviderBase, id = TOOL_NAME meta_type = TOOL_NAME.title().replace('_', ' ') - implements(IArchetypeTool) - isPrincipiaFolderish = True # Show up in the ZMI security = ClassSecurityInfo() diff --git a/Products/Archetypes/BaseBTreeFolder.py b/Products/Archetypes/BaseBTreeFolder.py index 8a45c7ca..92f45e09 100644 --- a/Products/Archetypes/BaseBTreeFolder.py +++ b/Products/Archetypes/BaseBTreeFolder.py @@ -5,7 +5,7 @@ from Products.CMFCore.CMFBTreeFolder import CMFBTreeFolder from AccessControl import ClassSecurityInfo from App.class_init import InitializeClass -from zope.interface import implements +from zope.interface import implementer # to keep backward compatibility has_btree = 1 @@ -22,13 +22,12 @@ class BaseBTreeFolder(Base): _ordering = 'unordered' # old large folder remain unordered at first +@implementer(IBaseFolder) class ObsoleteBaseBTreeFolder(CMFBTreeFolder, BaseFolder): """ A BaseBTreeFolder with all the bells and whistles""" security = ClassSecurityInfo() - implements(IBaseFolder) - # Fix permissions set by CopySupport.py __ac_permissions__ = ( (permissions.ModifyPortalContent, diff --git a/Products/Archetypes/BaseContent.py b/Products/Archetypes/BaseContent.py index 633bfb01..4e2df6ac 100644 --- a/Products/Archetypes/BaseContent.py +++ b/Products/Archetypes/BaseContent.py @@ -13,7 +13,7 @@ from Products.CMFCore.PortalContent import PortalContent from OFS.PropertyManager import PropertyManager -from zope.interface import implements +from zope.interface import implementer CONTENT_MANAGE_OPTIONS = ( {'action': 'manage_change_history_page', 'label': 'History'}, @@ -22,6 +22,7 @@ ) +@implementer(IBaseContent, IReferenceable) class BaseContentMixin(CatalogMultiplex, BaseObject, PortalContent, @@ -29,8 +30,6 @@ class BaseContentMixin(CatalogMultiplex, """A not-so-basic CMF Content implementation that doesn't include Dublin Core Metadata""" - implements(IBaseContent, IReferenceable) - security = ClassSecurityInfo() manage_options = CONTENT_MANAGE_OPTIONS @@ -75,14 +74,13 @@ def _notifyOfCopyTo(self, container, op=0): InitializeClass(BaseContentMixin) +@implementer(IBaseContent, IReferenceable, IExtensibleMetadata) class BaseContent(BaseContentMixin, ExtensibleMetadata, PropertyManager): """A not-so-basic CMF Content implementation with Dublin Core Metadata included""" - implements(IBaseContent, IReferenceable, IExtensibleMetadata) - schema = BaseContentMixin.schema + ExtensibleMetadata.schema def __init__(self, oid, **kwargs): diff --git a/Products/Archetypes/BaseFolder.py b/Products/Archetypes/BaseFolder.py index 3195b33e..ee43df10 100644 --- a/Products/Archetypes/BaseFolder.py +++ b/Products/Archetypes/BaseFolder.py @@ -18,7 +18,7 @@ from Products.CMFCore.utils import _checkPermission from zope import event -from zope.interface import implements +from zope.interface import implementer FOLDER_MANAGE_OPTIONS = ( {'action': 'manage_main', 'label': 'Contents'}, @@ -27,6 +27,7 @@ ) +@implementer(IBaseFolder, IBaseObject, IReferenceable, IContentish) class BaseFolderMixin(CatalogMultiplex, BaseObject, PortalFolder, @@ -34,8 +35,6 @@ class BaseFolderMixin(CatalogMultiplex, """A not-so-basic Folder implementation, with no Dublin Core Metadata""" - implements(IBaseFolder, IBaseObject, IReferenceable, IContentish) - security = ClassSecurityInfo() # Fix permissions set by CopySupport.py @@ -245,13 +244,12 @@ def manage_afterMKCOL(self, id, result, REQUEST=None, RESPONSE=None): InitializeClass(BaseFolderMixin) +@implementer(IBaseFolder, IBaseObject, IReferenceable, + IContentish, IExtensibleMetadata) class BaseFolder(BaseFolderMixin, ExtensibleMetadata): """A not-so-basic Folder implementation, with Dublin Core Metadata included""" - implements(IBaseFolder, IBaseObject, IReferenceable, - IContentish, IExtensibleMetadata) - schema = BaseFolderMixin.schema + ExtensibleMetadata.schema security = ClassSecurityInfo() diff --git a/Products/Archetypes/BaseObject.py b/Products/Archetypes/BaseObject.py index 20d4f0fc..083d64b9 100644 --- a/Products/Archetypes/BaseObject.py +++ b/Products/Archetypes/BaseObject.py @@ -54,7 +54,7 @@ from webdav.NullResource import NullResource from zope import event -from zope.interface import implements, Interface +from zope.interface import implementer, Interface from zope.component import subscribers from zope.component import queryMultiAdapter from zope.component import queryUtility @@ -111,6 +111,7 @@ ), marshall=RFC822Marshaller()) +@implementer(IBaseObject, IReferenceable) class BaseObject(Referenceable): security = ClassSecurityInfo() @@ -130,8 +131,6 @@ class BaseObject(Referenceable): _at_rename_after_creation = False # rename object according to title? - implements(IBaseObject, IReferenceable) - def __init__(self, oid, **kwargs): self.id = oid diff --git a/Products/Archetypes/BaseUnit.py b/Products/Archetypes/BaseUnit.py index f656f40e..d2349ace 100644 --- a/Products/Archetypes/BaseUnit.py +++ b/Products/Archetypes/BaseUnit.py @@ -1,5 +1,5 @@ import os.path -from zope.interface import implements +from zope.interface import implementer from Products.Archetypes.interfaces import IBaseUnit from Products.Archetypes.log import log @@ -17,8 +17,8 @@ _marker = [] +@implementer(IBaseUnit, IWriteLock) class BaseUnit(File): - implements(IBaseUnit, IWriteLock) isUnit = 1 mimetype = None diff --git a/Products/Archetypes/ExtensibleMetadata.py b/Products/Archetypes/ExtensibleMetadata.py index b3e9cf2c..e9205ae6 100644 --- a/Products/Archetypes/ExtensibleMetadata.py +++ b/Products/Archetypes/ExtensibleMetadata.py @@ -1,7 +1,7 @@ import string from logging import DEBUG from zope.component import queryUtility -from zope.interface import implements +from zope.interface import implementer from Products.Archetypes import PloneMessageFactory as _ from Products.Archetypes.Field import BooleanField, LinesField, TextField, \ @@ -45,12 +45,11 @@ # MIXIN +@implementer(IExtensibleMetadata) class ExtensibleMetadata(Persistence.Persistent): """ A DC metadata implementation for Plone Archetypes """ - implements(IExtensibleMetadata) - security = ClassSecurityInfo() schema = type = MetadataSchema(( diff --git a/Products/Archetypes/Field.py b/Products/Archetypes/Field.py index d4b764f8..1d9e2e9e 100644 --- a/Products/Archetypes/Field.py +++ b/Products/Archetypes/Field.py @@ -9,7 +9,7 @@ from zope.i18nmessageid import Message from zope import schema from zope import component -from zope.interface import implements +from zope.interface import implementer from AccessControl import ClassSecurityInfo from AccessControl import getSecurityManager @@ -159,6 +159,7 @@ def decode(value, instance, **kwargs): _field_count = 0 +@implementer(IField, ILayerContainer) class Field(DefaultLayerContainer): """ Extend `DefaultLayerContainer`. @@ -168,8 +169,6 @@ class Field(DefaultLayerContainer): field's property values. """ - implements(IField, ILayerContainer) - security = ClassSecurityInfo() _properties = { @@ -787,13 +786,13 @@ def getI18nDomain(self): setSecurity(Field) +@implementer(IObjectField, ILayerContainer) class ObjectField(Field): """Base Class for Field objects that fundamentaly deal with raw data. This layer implements the interface to IStorage and other Field Types should subclass this to delegate through the storage layer. """ - implements(IObjectField, ILayerContainer) _properties = Field._properties.copy() _properties.update({ @@ -956,6 +955,7 @@ def get_size(self, instance): setSecurity(ObjectField) +@implementer(IStringField) class StringField(ObjectField): """A field that stores strings""" _properties = Field._properties.copy() @@ -965,8 +965,6 @@ class StringField(ObjectField): 'default_content_type': 'text/plain', }) - implements(IStringField) - security = ClassSecurityInfo() security.declarePrivate('get') @@ -988,12 +986,11 @@ def set(self, instance, value, **kwargs): self.getName(), instance, value, **kwargs) +@implementer(IFileField, ILayerContainer) class FileField(ObjectField): """Something that may be a file, but is not an image and doesn't want text format conversion""" - implements(IFileField, ILayerContainer) - _properties = ObjectField._properties.copy() _properties.update({ 'type': 'file', @@ -1367,6 +1364,7 @@ def getIndexable(self, instance): return value +@implementer(ITextField) class TextField(FileField): """Base Class for Field objects that rely on some type of transformation""" @@ -1383,8 +1381,6 @@ class TextField(FileField): 'content_class': BaseUnit, }) - implements(ITextField) - security = ClassSecurityInfo() security.declarePublic('defaultView') @@ -1583,6 +1579,7 @@ def get_size(self, instance): return len(self.getBaseUnit(instance)) +@implementer(IDateTimeField) class DateTimeField(ObjectField): """A field that stores dates and times""" @@ -1592,8 +1589,6 @@ class DateTimeField(ObjectField): 'widget': CalendarWidget, }) - implements(IDateTimeField) - security = ClassSecurityInfo() security.declarePrivate('validate_required') @@ -1634,6 +1629,7 @@ def set(self, instance, value, **kwargs): ObjectField.set(self, instance, value, **kwargs) +@implementer(ILinesField) class LinesField(ObjectField): """For creating lines objects""" @@ -1644,8 +1640,6 @@ class LinesField(ObjectField): 'widget': LinesWidget, }) - implements(ILinesField) - security = ClassSecurityInfo() security.declarePrivate('set') @@ -1691,6 +1685,7 @@ def get_size(self, instance): return size +@implementer(IIntegerField) class IntegerField(ObjectField): """A field that stores an integer""" @@ -1702,8 +1697,6 @@ class IntegerField(ObjectField): 'default': None, }) - implements(IIntegerField) - security = ClassSecurityInfo() security.declarePrivate('validate_required') @@ -1730,6 +1723,7 @@ def set(self, instance, value, **kwargs): ObjectField.set(self, instance, value, **kwargs) +@implementer(IFloatField) class FloatField(ObjectField): """A field that stores floats""" _properties = Field._properties.copy() @@ -1738,8 +1732,6 @@ class FloatField(ObjectField): 'default': None }) - implements(IFloatField) - security = ClassSecurityInfo() security.declarePrivate('validate_required') @@ -1770,6 +1762,7 @@ def set(self, instance, value, **kwargs): ObjectField.set(self, instance, value, **kwargs) +@implementer(IFixedPointField) class FixedPointField(ObjectField): """A field for storing numerical data with fixed points @@ -1791,8 +1784,6 @@ class FixedPointField(ObjectField): 'validators': ('isDecimal'), }) - implements(IFixedPointField) - security = ClassSecurityInfo() def _to_tuple(self, instance, value): @@ -1905,6 +1896,7 @@ def get(self, instance, **kwargs): return template % (sign, front, fra) +@implementer(IReferenceField) class ReferenceField(ObjectField): """A field for creating references between objects. @@ -1938,8 +1930,6 @@ class ReferenceField(ObjectField): 'index_method': '_at_edit_accessor', }) - implements(IReferenceField) - security = ClassSecurityInfo() referencesSortable = False @@ -2214,6 +2204,7 @@ def get_size(self, instance): return 0 +@implementer(IComputedField) class ComputedField(Field): """A field that always returns a computed.""" _properties = Field._properties.copy() @@ -2225,8 +2216,6 @@ class ComputedField(Field): 'storage': ReadOnlyStorage(), }) - implements(IComputedField) - security = ClassSecurityInfo() security.declarePrivate('set') @@ -2250,6 +2239,7 @@ def get_size(self, instance): return 0 +@implementer(IBooleanField) class BooleanField(ObjectField): """A field that stores boolean values.""" _properties = Field._properties.copy() @@ -2260,8 +2250,6 @@ class BooleanField(ObjectField): 'widget': BooleanWidget, }) - implements(IBooleanField) - security = ClassSecurityInfo() security.declarePrivate('get') @@ -2401,6 +2389,7 @@ def isBinary(self): return True +@implementer(IImageField) class ImageField(FileField): """ implements an image attribute. it stores it's data in an image sub-object @@ -2488,8 +2477,6 @@ class ImageField(FileField): 'content_class': Image, }) - implements(IImageField) - security = ClassSecurityInfo() default_view = "view" diff --git a/Products/Archetypes/Layer.py b/Products/Archetypes/Layer.py index 7e165526..c9b718f1 100644 --- a/Products/Archetypes/Layer.py +++ b/Products/Archetypes/Layer.py @@ -2,11 +2,11 @@ from ExtensionClass import Base from App.class_init import InitializeClass from AccessControl import ClassSecurityInfo -from zope.interface import implements +from zope.interface import implementer +@implementer(ILayerContainer) class DefaultLayerContainer(Base): - implements(ILayerContainer) security = ClassSecurityInfo() diff --git a/Products/Archetypes/Marshall.py b/Products/Archetypes/Marshall.py index d6e37332..d2cf31f0 100644 --- a/Products/Archetypes/Marshall.py +++ b/Products/Archetypes/Marshall.py @@ -4,7 +4,7 @@ from rfc822 import Message from zope.contenttype import guess_content_type -from zope.interface import implements +from zope.interface import implementer from AccessControl import ClassSecurityInfo from Acquisition import aq_base @@ -102,8 +102,8 @@ def parseRFC822(body): return headers, buffer.read() +@implementer(IMarshall, ILayer) class Marshaller: - implements(IMarshall, ILayer) security = ClassSecurityInfo() security.declareObjectPrivate() diff --git a/Products/Archetypes/OrderedBaseFolder.py b/Products/Archetypes/OrderedBaseFolder.py index 65525fd0..31861406 100644 --- a/Products/Archetypes/OrderedBaseFolder.py +++ b/Products/Archetypes/OrderedBaseFolder.py @@ -3,7 +3,7 @@ OrderedBaseFolder derived from OrderedFolder by Stephan Richter, iuveno AG. """ -from zope.interface import implements +from zope.interface import implementer from AccessControl import ClassSecurityInfo from App.class_init import InitializeClass @@ -62,11 +62,10 @@ def getObjectPosition(self, id): InitializeClass(OrderedContainer) +@implementer(IDynamicType) class OrderedBaseFolder(BaseFolder, OrderedContainer): """ An ordered base folder implementation """ - implements(IDynamicType) - security = ClassSecurityInfo() def __init__(self, oid, **kwargs): diff --git a/Products/Archetypes/ReferenceEngine.py b/Products/Archetypes/ReferenceEngine.py index 66248004..36003c05 100644 --- a/Products/Archetypes/ReferenceEngine.py +++ b/Products/Archetypes/ReferenceEngine.py @@ -2,7 +2,7 @@ from types import StringType, UnicodeType import time import urllib -from zope.interface import implements +from zope.interface import implementer from Products.CMFCore.utils import getToolByName from Products.Archetypes.interfaces.referenceable import IReferenceable @@ -42,15 +42,8 @@ from UIDCatalog import UIDResolver +@implementer(IReference) class Reference(Referenceable, SimpleItem): - # Added base level support for referencing References - # They respond to the UUID protocols, but are not - # catalog aware. This means that you can't move/rename - # reference objects and expect them to work, but you can't - # do this anyway. However they should fine the correct - # events when they are added/deleted, etc - - implements(IReference) security = ClassSecurityInfo() portal_type = 'Reference' @@ -154,11 +147,10 @@ def manage_beforeDelete(self, item, container): REFERENCE_CONTENT_INSTANCE_NAME = 'content' +@implementer(IContentReference) class ContentReference(ObjectManager, Reference): '''Subclass of Reference to support contentish objects inside references ''' - implements(IContentReference) - def __init__(self, *args, **kw): Reference.__init__(self, *args, **kw) @@ -280,13 +272,13 @@ def Title(self): return self._obj.getId() +@implementer(IReferenceCatalog) class ReferenceCatalog(UniqueObject, UIDResolver, ZCatalog): """Reference catalog """ id = REFERENCE_CATALOG security = ClassSecurityInfo() - implements(IReferenceCatalog) manage_catalogFind = DTMLFile('catalogFind', _catalog_dtml) manage_options = ZCatalog.manage_options diff --git a/Products/Archetypes/Referenceable.py b/Products/Archetypes/Referenceable.py index ed5d4271..a482f216 100644 --- a/Products/Archetypes/Referenceable.py +++ b/Products/Archetypes/Referenceable.py @@ -1,4 +1,4 @@ -from zope.interface import implements +from zope.interface import implementer from plone.uuid.interfaces import IUUID @@ -30,10 +30,10 @@ #### +@implementer(IReferenceable) class Referenceable(CopySource): """ A Mix-in for Referenceable objects """ isReferenceable = 1 - implements(IReferenceable) security = ClassSecurityInfo() # Note: methods of this class are made non-publishable by not giving them diff --git a/Products/Archetypes/SQLStorage.py b/Products/Archetypes/SQLStorage.py index ae4e998a..934739d7 100644 --- a/Products/Archetypes/SQLStorage.py +++ b/Products/Archetypes/SQLStorage.py @@ -1,4 +1,4 @@ -from zope.interface import implements +from zope.interface import implementer from Acquisition import aq_base, aq_inner, aq_parent from OFS.ObjectManager import BeforeDeleteException @@ -14,11 +14,10 @@ from Products.CMFCore.utils import getToolByName +@implementer(ISQLStorage, ILayer) class BaseSQLStorage(StorageLayer): """ SQLStorage Base, more or less ISO SQL """ - implements(ISQLStorage, ILayer) - query_create = ('create table ' '(UID char(50) primary key not null, ' 'PARENTUID char(50), )') diff --git a/Products/Archetypes/Schema/Composite.py b/Products/Archetypes/Schema/Composite.py index 59651aec..25a1d0f7 100644 --- a/Products/Archetypes/Schema/Composite.py +++ b/Products/Archetypes/Schema/Composite.py @@ -10,9 +10,10 @@ from App.class_init import InitializeClass from Acquisition import Implicit, aq_parent, aq_inner from Products.CMFCore.permissions import View, ModifyPortalContent -from zope.interface import implements +from zope.interface import implementer +@implementer(ICompositeSchema, ILayerRuntime, ILayerContainer) class CompositeSchema(Implicit): """Act on behalf of a set of Schemas, pretending it was a single one. @@ -20,8 +21,6 @@ class CompositeSchema(Implicit): Note that if field names overlap, they last schema wins. """ - implements(ICompositeSchema, ILayerRuntime, ILayerContainer) - security = ClassSecurityInfo() security.setDefaultAccess('allow') diff --git a/Products/Archetypes/Schema/Facade.py b/Products/Archetypes/Schema/Facade.py index a2236e9b..b7ce3547 100644 --- a/Products/Archetypes/Schema/Facade.py +++ b/Products/Archetypes/Schema/Facade.py @@ -9,7 +9,7 @@ from AccessControl import ClassSecurityInfo from Products.CMFCore.utils import getToolByName from Products.CMFCore.permissions import View -from zope.interface import implements +from zope.interface import implementer # Crude mapping for now. We should instantiate @@ -100,13 +100,12 @@ def __get__(self, obj, objtype=None): return fieldNamesFromSet(set, obj) +@implementer(IBindableSchema) class FacadeMetadataSchema(BasicSchema): """A Facade Schema, which adapts CMFMetadata 'Sets' to groups of Archetypes fields """ - implements(IBindableSchema) - security = ClassSecurityInfo() security.setDefaultAccess('allow') diff --git a/Products/Archetypes/Schema/__init__.py b/Products/Archetypes/Schema/__init__.py index dcb86ce5..c0e6551a 100644 --- a/Products/Archetypes/Schema/__init__.py +++ b/Products/Archetypes/Schema/__init__.py @@ -19,7 +19,7 @@ from App.class_init import InitializeClass from Products.CMFCore import permissions from Products.CMFCore.utils import getToolByName -from zope.interface import implements +from zope.interface import implementer __docformat__ = 'reStructuredText' _marker = [] @@ -44,6 +44,7 @@ def getSchemata(obj): return schemata +@implementer(ISchemata) class Schemata(Base): """Manage a list of fields by grouping them together. @@ -53,8 +54,6 @@ class Schemata(Base): security = ClassSecurityInfo() security.setDefaultAccess('allow') - implements(ISchemata) - def __init__(self, name='default', fields=None): """Initialize Schemata and add optional fields.""" @@ -413,11 +412,10 @@ def copy(self): InitializeClass(SchemaLayerContainer) +@implementer(ISchema) class BasicSchema(Schemata): """Manage a list of fields and run methods over them.""" - implements(ISchema) - security = ClassSecurityInfo() security.setDefaultAccess('allow') @@ -702,13 +700,12 @@ def replaceField(self, name, field): InitializeClass(BasicSchema) +@implementer(ILayerRuntime, ILayerContainer, ISchema) class Schema(BasicSchema, SchemaLayerContainer): """ Schema """ - implements(ILayerRuntime, ILayerContainer, ISchema) - security = ClassSecurityInfo() security.setDefaultAccess('allow') @@ -932,6 +929,7 @@ class WrappedSchema(Schema, Explicit): InitializeClass(WrappedSchema) +@implementer(IManagedSchema) class ManagedSchema(Schema): """ Managed Schema @@ -940,8 +938,6 @@ class ManagedSchema(Schema): security = ClassSecurityInfo() security.setDefaultAccess('allow') - implements(IManagedSchema) - security.declareProtected(permissions.ModifyPortalContent, 'delSchemata') diff --git a/Products/Archetypes/Storage/__init__.py b/Products/Archetypes/Storage/__init__.py index 7bb9fc55..8a13d517 100644 --- a/Products/Archetypes/Storage/__init__.py +++ b/Products/Archetypes/Storage/__init__.py @@ -8,7 +8,7 @@ from AccessControl import ClassSecurityInfo from Products.Archetypes.Registry import setSecurity, registerStorage -from zope.interface import implements +from zope.interface import implementer type_map = {'text': 'string', 'datetime': 'date', @@ -20,12 +20,11 @@ # XXX subclass from Base? +@implementer(IStorage) class Storage: """Basic, abstract class for Storages. You need to implement at least those methods""" - implements(IStorage) - security = ClassSecurityInfo() security.declarePublic('getName') @@ -63,13 +62,12 @@ class ReadOnlyStorage(Storage): security = ClassSecurityInfo() +@implementer(IStorage, ILayer) class StorageLayer(Storage): """Base, abstract StorageLayer. Storages that need to manipulate how they are initialized per instance and/or per field must subclass and implement those methods""" - implements(IStorage, ILayer) - security = ClassSecurityInfo() security.declarePrivate('initializeInstance') diff --git a/Products/Archetypes/TemplateMixin.py b/Products/Archetypes/TemplateMixin.py index 66720d04..f0f146c7 100644 --- a/Products/Archetypes/TemplateMixin.py +++ b/Products/Archetypes/TemplateMixin.py @@ -11,7 +11,7 @@ from Acquisition import aq_base from Acquisition import aq_inner from ExtensionClass import Base -from zope.interface import implements +from zope.interface import implementer TemplateMixinSchema = Schema(( @@ -30,8 +30,8 @@ )) +@implementer(ITemplateMixin) class TemplateMixin(Base): - implements(ITemplateMixin) schema = TemplateMixinSchema diff --git a/Products/Archetypes/UIDCatalog.py b/Products/Archetypes/UIDCatalog.py index c351e86c..9bf2e0b1 100644 --- a/Products/Archetypes/UIDCatalog.py +++ b/Products/Archetypes/UIDCatalog.py @@ -2,7 +2,7 @@ import os import time import urllib -from zope.interface import implements +from zope.interface import implementer from zope import component from zope import interface @@ -197,13 +197,13 @@ class UIDBaseCatalog(PluggableCatalog): BASE_CLASS = UIDCatalogBrains +@implementer(IUIDCatalog) class UIDCatalog(UniqueObject, UIDResolver, ZCatalog): """Unique id catalog """ id = UID_CATALOG security = ClassSecurityInfo() - implements(IUIDCatalog) manage_catalogFind = DTMLFile('catalogFind', _catalog_dtml) diff --git a/Products/Archetypes/WebDAVSupport.py b/Products/Archetypes/WebDAVSupport.py index ef3f492e..e6e05aed 100644 --- a/Products/Archetypes/WebDAVSupport.py +++ b/Products/Archetypes/WebDAVSupport.py @@ -9,13 +9,12 @@ from Products.Archetypes.event import WebDAVObjectInitializedEvent from Products.Archetypes.event import WebDAVObjectEditedEvent from Products.Archetypes.utils import shasattr, mapply -from zope.interface import implements, Interface +from zope.interface import implementer, Interface +@implementer(IStreamIterator) class PdataStreamIterator(object): - implements(IStreamIterator) - def __init__(self, data, size, streamsize=1 << 16): # Consume the whole data into a TemporaryFile when # constructing, otherwise we might end up loading the whole diff --git a/Products/Archetypes/annotations.py b/Products/Archetypes/annotations.py index 9c82b08e..4d8447b3 100644 --- a/Products/Archetypes/annotations.py +++ b/Products/Archetypes/annotations.py @@ -34,7 +34,7 @@ from Products.Archetypes.interfaces.annotations import IATAnnotations from Products.Archetypes.interfaces.annotations import IATAnnotatable -from zope.interface import implements +from zope.interface import implementer from zope.component import adapts # annotation keys @@ -47,11 +47,11 @@ AT_ANN_KEYS = (AT_ANN_STORAGE, AT_MD_STORAGE, AT_FIELD_MD, AT_REF) +@implementer(IATAnnotations) class ATAnnotations(DictMixin, Explicit): """Store annotations in the '__annotations__' attribute on a IATAnnotatable object. """ - implements(IATAnnotations) adapts(IATAnnotatable) security = ClassSecurityInfo() diff --git a/Products/Archetypes/athistoryaware.py b/Products/Archetypes/athistoryaware.py index 776bfa9f..dde23d2d 100644 --- a/Products/Archetypes/athistoryaware.py +++ b/Products/Archetypes/athistoryaware.py @@ -37,7 +37,7 @@ from annotations import AT_ANN_KEYS from interfaces.athistoryaware import IATHistoryAware -from zope.interface import implements +from zope.interface import implementer # A note about this implementation # @@ -111,6 +111,7 @@ def _objectRevisions(obj, limit=10): yield tid, rev +@implementer(IATHistoryAware) class ATHistoryAwareMixin: """Archetypes history aware mixin class @@ -119,8 +120,6 @@ class ATHistoryAwareMixin: """ - implements(IATHistoryAware) - security = ClassSecurityInfo() security.declarePrivate('_constructAnnotatedHistory') diff --git a/Products/Archetypes/browser/edit.py b/Products/Archetypes/browser/edit.py index 330de733..ae62fa42 100644 --- a/Products/Archetypes/browser/edit.py +++ b/Products/Archetypes/browser/edit.py @@ -1,5 +1,5 @@ from zope.component import queryUtility -from zope.interface import implements +from zope.interface import implementer from Acquisition import aq_inner from zExceptions import Unauthorized @@ -19,8 +19,8 @@ ID_NORMALIZER = False +@implementer(IEditForm) class Edit(BrowserView): - implements(IEditForm) def isTemporaryObject(self): factory = getToolByName(aq_inner(self.context), 'portal_factory', None) diff --git a/Products/Archetypes/browser/utils.py b/Products/Archetypes/browser/utils.py index 1c9cabc1..6909a603 100644 --- a/Products/Archetypes/browser/utils.py +++ b/Products/Archetypes/browser/utils.py @@ -1,11 +1,11 @@ -from zope.interface import implements +from zope.interface import implementer from Products.Five import BrowserView from Products.Archetypes.interfaces.utils import IUtils from zope.i18n import translate +@implementer(IUtils) class Utils(BrowserView): - implements(IUtils) def translate(self, vocab, value, widget=None): """Translate an input value from a vocabulary. diff --git a/Products/Archetypes/event.py b/Products/Archetypes/event.py index e70a715f..1c051053 100644 --- a/Products/Archetypes/event.py +++ b/Products/Archetypes/event.py @@ -1,7 +1,7 @@ """Event definitions """ -from zope.interface import implements +from zope.interface import implementer from zope.component.interfaces import ObjectEvent from zope.lifecycleevent import ObjectModifiedEvent @@ -16,37 +16,37 @@ # Modification +@implementer(IObjectInitializedEvent) class ObjectInitializedEvent(ObjectModifiedEvent): """An object is being initialised, i.e. populated for the first time """ - implements(IObjectInitializedEvent) +@implementer(IWebDAVObjectInitializedEvent) class WebDAVObjectInitializedEvent(ObjectInitializedEvent): """An object is being initialised via WebDAV """ - implements(IWebDAVObjectInitializedEvent) +@implementer(IObjectEditedEvent) class ObjectEditedEvent(ObjectModifiedEvent): """An object is being edited, i.e. modified after the first save """ - implements(IObjectEditedEvent) +@implementer(IWebDAVObjectEditedEvent) class WebDAVObjectEditedEvent(ObjectEditedEvent): """An object is being edited via WebDAV """ - implements(IWebDAVObjectEditedEvent) +@implementer(IEditBegunEvent) class EditBegunEvent(ObjectEvent): """An edit operation was begun """ - implements(IEditBegunEvent) +@implementer(IEditCancelledEvent) class EditCancelledEvent(ObjectEvent): """An edit operation was cancelled """ - implements(IEditCancelledEvent) diff --git a/Products/Archetypes/generator/widget.py b/Products/Archetypes/generator/widget.py index 97d6ea5e..d004b7c9 100644 --- a/Products/Archetypes/generator/widget.py +++ b/Products/Archetypes/generator/widget.py @@ -5,7 +5,7 @@ from zope.i18n import translate from zope.i18nmessageid import Message -from zope.interface import Interface, implements +from zope.interface import Interface, implementer class iwidget(Interface): @@ -28,6 +28,7 @@ def Description(instance): """Returns the description, possibly translated.""" +@implementer(iwidget) class widget: """Base class for widgets. @@ -40,8 +41,6 @@ class widget: condition -- TALES expression to control the widget display """ - implements(iwidget) - security = ClassSecurityInfo() security.declareObjectPublic() security.setDefaultAccess('allow') diff --git a/Products/Archetypes/tests/test_event.py b/Products/Archetypes/tests/test_event.py index 41ae3743..842b4220 100644 --- a/Products/Archetypes/tests/test_event.py +++ b/Products/Archetypes/tests/test_event.py @@ -2,7 +2,7 @@ Unittests for the events fired by Archetypes. """ -from zope.interface import implements, Interface, directlyProvides +from zope.interface import implementer, Interface, directlyProvides from zope import component from Products.Archetypes.tests.atsitetestcase import ATSiteTestCase @@ -40,8 +40,8 @@ class Dummy(BaseContent): # Subscription adapters for validation +@implementer(IObjectPreValidation) class PreValidation(object): - implements(IObjectPreValidation) def __init__(self, context): self.context = context @@ -50,8 +50,8 @@ def __call__(self, request): return dict(foo="Foo was invalid.") +@implementer(IObjectPostValidation) class PostValidation(object): - implements(IObjectPostValidation) def __init__(self, context): self.context = context diff --git a/Products/Archetypes/tests/test_fields.py b/Products/Archetypes/tests/test_fields.py index fad515c7..58376a2b 100644 --- a/Products/Archetypes/tests/test_fields.py +++ b/Products/Archetypes/tests/test_fields.py @@ -27,7 +27,7 @@ import PIL from zope.annotation.interfaces import IAttributeAnnotatable -from zope.interface import implements, alsoProvides +from zope.interface import implementer, alsoProvides from zope.component import getSiteManager from zope.publisher.browser import TestRequest from zope.schema.interfaces import IVocabularyFactory @@ -134,8 +134,8 @@ sampleDisplayList = DisplayList([('e1', 'e1'), ('element2', 'element2')]) +@implementer(IVocabulary) class sampleInterfaceVocabulary: - implements(IVocabulary) def getDisplayList(self, instance): return sampleDisplayList @@ -154,8 +154,8 @@ def default_val(self): return "World" +@implementer(IVocabularyFactory) class DummyVocabulary(object): - implements(IVocabularyFactory) def __call__(self, context): return SimpleVocabulary.fromItems([("title1", "value1"), ("t2", "v2")]) @@ -163,8 +163,8 @@ def __call__(self, context): DummyVocabFactory = DummyVocabulary() +@implementer(IVocabularyFactory) class DummyIntVocabulary(object): - implements(IVocabularyFactory) def __call__(self, context): return SimpleVocabulary.fromItems([("title1", 1), ("t2", 2)]) @@ -523,8 +523,8 @@ def test_defaults(self): # Adapter field.default_method = None + @implementer(IFieldDefaultProvider) class DefaultFor(object): - implements(IFieldDefaultProvider) def __init__(self, context): self.context = context diff --git a/Products/Archetypes/tests/test_fieldvalidation.py b/Products/Archetypes/tests/test_fieldvalidation.py index 445614ab..14f4b236 100644 --- a/Products/Archetypes/tests/test_fieldvalidation.py +++ b/Products/Archetypes/tests/test_fieldvalidation.py @@ -31,11 +31,11 @@ from Products.Archetypes.BaseObject import BaseObject from Products.validation import validation as validationService from Products.validation.interfaces.IValidator import IValidator -from zope.interface import implements +from zope.interface import implementer +@implementer(IValidator) class MyValidator: - implements(IValidator) def __init__(self, name, fun): self.name = name diff --git a/Products/Archetypes/tests/test_pawidgets.py b/Products/Archetypes/tests/test_pawidgets.py index 24213587..d624bd65 100644 --- a/Products/Archetypes/tests/test_pawidgets.py +++ b/Products/Archetypes/tests/test_pawidgets.py @@ -313,14 +313,15 @@ def setUp(self): def test_multi_valued(self): from zope.event import notify - from zope.interface import implements + from zope.interface import implementer from zope.lifecycleevent import ObjectCreatedEvent from plone.uuid.interfaces import IUUID from plone.uuid.interfaces import IAttributeUUID from Products.Archetypes.Widget import RelatedItemsWidget + @implementer(IAttributeUUID) class ExampleContent(object): - implements(IAttributeUUID) + pass obj1 = ExampleContent() obj2 = ExampleContent() @@ -362,14 +363,15 @@ class ExampleContent(object): def test_single_value(self): from zope.event import notify - from zope.interface import implements + from zope.interface import implementer from zope.lifecycleevent import ObjectCreatedEvent from plone.uuid.interfaces import IUUID from plone.uuid.interfaces import IAttributeUUID from Products.Archetypes.Widget import RelatedItemsWidget + @implementer(IAttributeUUID) class ExampleContent(object): - implements(IAttributeUUID) + pass obj1 = ExampleContent() notify(ObjectCreatedEvent(obj1)) @@ -446,13 +448,14 @@ def test_single_valued_empty(self): def test_multiple_widgets(self): from zope.event import notify from Products.Archetypes.Widget import RelatedItemsWidget - from zope.interface import implements + from zope.interface import implementer from zope.lifecycleevent import ObjectCreatedEvent from plone.uuid.interfaces import IUUID from plone.uuid.interfaces import IAttributeUUID + @implementer(IAttributeUUID) class ExampleContent(object): - implements(IAttributeUUID) + pass obj1 = ExampleContent() obj2 = ExampleContent() diff --git a/Products/Archetypes/tests/test_referenceCatalog.py b/Products/Archetypes/tests/test_referenceCatalog.py index c13f3c21..a92144e2 100644 --- a/Products/Archetypes/tests/test_referenceCatalog.py +++ b/Products/Archetypes/tests/test_referenceCatalog.py @@ -43,9 +43,9 @@ from Acquisition import Explicit +@interface.implementer(IAttributeUUID) class DexterityLike(Explicit): """Create a new class non based on Archetypes""" - interface.implements(IAttributeUUID) def __init__(self): self.id = "myid"