Skip to content

Commit

Permalink
Merge pull request #38 from plone/gforcada-use-zope-decorators
Browse files Browse the repository at this point in the history
Use zope.interface decorator
  • Loading branch information
gforcada authored Jul 10, 2016
2 parents 7a29d0c + 0911a31 commit e0d31c4
Show file tree
Hide file tree
Showing 12 changed files with 71 additions and 107 deletions.
3 changes: 2 additions & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ New features:

Bug fixes:

- *add item here*
- Use zope.interface decorator.
[gforcada]


2.2.20 (2016-04-15)
Expand Down
18 changes: 9 additions & 9 deletions Products/CMFEditions/ArchivistTool.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import time
from StringIO import StringIO
from cPickle import Pickler, Unpickler
from zope.interface import implements, alsoProvides
from zope.interface import implementer, alsoProvides

from App.class_init import InitializeClass
from Persistence import Persistent
Expand Down Expand Up @@ -72,10 +72,10 @@ def deepcopy(obj):
u = Unpickler(stream)
return u.load()

@implementer(IVersionData)
class VersionData:
"""
"""
implements(IVersionData)

def __init__(self, data, refs_to_be_deleted, attr_handling_references,
preserved_data, metadata):
Expand All @@ -87,8 +87,8 @@ def __init__(self, data, refs_to_be_deleted, attr_handling_references,
self.app_metadata = metadata['app_metadata']


@implementer(IAttributeAdapter)
class AttributeAdapter(Persistent):
implements(IAttributeAdapter)

def __init__(self, parent, attr_name, type=None):
self._parent = aq_base(parent)
Expand All @@ -109,8 +109,8 @@ def getAttributeName(self):
def getType(self):
return self._type

@implementer(IAttributeAdapter)
class ObjectManagerStorageAdapter(Persistent):
implements(IAttributeAdapter)

def __init__(self, parent, attr_name, type=None):
self._parent = aq_base(parent)
Expand All @@ -135,10 +135,10 @@ def getType(self):
return self._type


@implementer(IVersionAwareReference)
class VersionAwareReference(Persistent):
"""A Reference that is version aware (and in future also location aware).
"""
implements(IVersionAwareReference)

def __init__(self, **info):
self.history_id = None
Expand Down Expand Up @@ -172,10 +172,10 @@ def __of__(self, obj):
return self


@implementer(IArchivistTool, IArchivist, IPurgeSupport)
class ArchivistTool(UniqueObject, SimpleItem):
"""
"""
implements(IArchivistTool, IArchivist, IPurgeSupport)

id = 'portal_archivist'
alternative_id = 'portal_standard_archivist'
Expand Down Expand Up @@ -405,21 +405,21 @@ def getUserId():
return getSecurityManager().getUser().getUserName()


@implementer(IObjectData)
class ObjectData(Persistent):
"""
"""
implements(IObjectData)

def __init__(self, obj, inside_refs=(), outside_refs=()):
self.object = obj
self.inside_refs = inside_refs
self.outside_refs = outside_refs


@implementer(IPreparedObject)
class PreparedObject:
"""
"""
implements(IPreparedObject)

def __init__(self, history_id, original, clone, referenced_data,
app_metadata, sys_metadata, is_registered, approxSize):
Expand Down Expand Up @@ -460,10 +460,10 @@ def copyVersionIdFromClone(self):
self.original.object.version_id = self.clone.object.version_id


@implementer(IHistory)
class LazyHistory:
"""Lazy history.
"""
implements(IHistory)

def __init__(self, archivist, obj, history_id, preserve, countPurged):
"""Sets up a lazy history.
Expand Down
18 changes: 8 additions & 10 deletions Products/CMFEditions/CopyModifyMergeRepositoryTool.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
from OFS.SimpleItem import SimpleItem
from BTrees.OOBTree import OOBTree
from zope.event import notify
from zope.interface import implements, Interface
from zope.interface import implementer, Interface
from zope.lifecycleevent import ObjectModifiedEvent
from Products.CMFCore.utils import UniqueObject, getToolByName
from Products.CMFCore.utils import _checkPermission
Expand Down Expand Up @@ -88,19 +88,17 @@ class IBaseObject(Interface):
'enable': 'enablePolicyOnTypeHook',
'disable': 'disablePolicyOnTypeHook'}

@implementer(
IPurgeSupport,
ICopyModifyMergeRepository,
IContentTypeVersionPolicySupport,
IRepositoryTool,)
class CopyModifyMergeRepositoryTool(UniqueObject,
SimpleItem):

"""See ICopyModifyMergeRepository
"""

implements(
IPurgeSupport,
ICopyModifyMergeRepository,
IContentTypeVersionPolicySupport,
IRepositoryTool,
)

id = 'portal_repository'
alternative_id = 'portal_copymergerepository'

Expand Down Expand Up @@ -739,10 +737,10 @@ def createTestHierarchy(self, context):
createTestHierarchy(context)


@implementer(IVersionData)
class VersionData:
"""
"""
implements(IVersionData)

security = ClassSecurityInfo()
security.declareObjectPublic()
Expand All @@ -761,10 +759,10 @@ def __init__(self, object, preserved_data, sys_metadata, app_metadata):
self.version_id = object.version_id


@implementer(IHistory)
class LazyHistory:
"""Lazy history.
"""
implements(IHistory)

__allow_access_to_unprotected_subobjects__ = 1

Expand Down
5 changes: 2 additions & 3 deletions Products/CMFEditions/KeepLastNVersionsTool.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"""
__version__ = "$Revision$"

from zope.interface import implements
from zope.interface import implementer

from App.class_init import InitializeClass
from AccessControl import ClassSecurityInfo
Expand All @@ -39,12 +39,11 @@
from Products.CMFEditions.interfaces import IPurgePolicyTool
from Products.CMFEditions.interfaces.IPurgePolicy import IPurgePolicy

@implementer(IPurgePolicyTool, IPurgePolicy)
class KeepLastNVersionsTool(UniqueObject, SimpleItem, PropertyManager):
"""
"""

implements(IPurgePolicyTool, IPurgePolicy)

id = 'portal_purgepolicy'
alternative_id = 'portal_keeplastnversions'

Expand Down
12 changes: 5 additions & 7 deletions Products/CMFEditions/ModifierRegistryTool.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"""

from zope.interface import implements
from zope.interface import implementer

from App.class_init import InitializeClass
from Missing import MV
Expand Down Expand Up @@ -52,16 +52,14 @@
from Products.CMFEditions.Modifiers import ConditionalTalesModifier


class ModifierRegistryTool(UniqueObject, OrderedFolder):
__doc__ = __doc__ # copy from module

implements(
@implementer(
IAttributeModifier, ISaveRetrieveModifier, ICloneModifier,
IModifierRegistrySet,
IModifierRegistryQuery,
# IBulkEditableSubscriberRegistry, # not yet implemented
IPortalModifierTool,
)
IPortalModifierTool,)
class ModifierRegistryTool(UniqueObject, OrderedFolder):
__doc__ = __doc__ # copy from module

id = 'portal_modifier'
alternative_id = 'portal_modifierregistry'
Expand Down
14 changes: 5 additions & 9 deletions Products/CMFEditions/Modifiers.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

from App.class_init import InitializeClass
from Acquisition import aq_base, aq_parent, aq_inner
from zope.interface import implements
from zope.interface import implementer

from OFS.SimpleItem import SimpleItem
from Products.PageTemplates.PageTemplateFile import PageTemplateFile
Expand All @@ -43,14 +43,12 @@
globals(),
__name__='manage_addModifierForm')

@implementer(
IConditionalModifier,)
class ConditionalModifier(SimpleItem):
"""This is a wrapper for a modifier.
"""

implements(
IConditionalModifier,
)

modifierEditForm = PageTemplateFile('www/modifierEditForm.pt',
globals(),
__name__='modifierEditForm')
Expand Down Expand Up @@ -105,14 +103,12 @@ def getModifier(self):
globals(),
__name__='manage_addTalesModifierForm')

@implementer(
IConditionalTalesModifier,)
class ConditionalTalesModifier(ConditionalModifier):
"""This is a wrapper with a tales condition for a modifier.
"""

implements(
IConditionalTalesModifier,
)

modifierEditForm = PageTemplateFile('www/talesModifierEditForm.pt',
globals(),
__name__='modifierEditForm')
Expand Down
8 changes: 3 additions & 5 deletions Products/CMFEditions/ReferenceFactoriesTool.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

from App.class_init import InitializeClass
from AccessControl import ClassSecurityInfo
from zope.interface import implements
from zope.interface import implementer

from Acquisition import aq_parent, aq_inner
from OFS.OrderedFolder import OrderedFolder
Expand All @@ -38,13 +38,11 @@
from Products.CMFEditions.interfaces.IReferenceFactories \
import IReferenceFactories

@implementer(
IReferenceFactories,)
class ReferenceFactoriesTool(UniqueObject, OrderedFolder):
__doc__ = __doc__ # copy from module

implements(
IReferenceFactories,
)

id = 'portal_referencefactories'
alternative_id = 'portal_referencefactoryregistry'

Expand Down
Loading

0 comments on commit e0d31c4

Please sign in to comment.