Skip to content

Commit

Permalink
Use zope.interface decorator
Browse files Browse the repository at this point in the history
This not only makes code more pleasent to read,
but also makes the code python 3 compatible
(while maintaining python 2 compatibility).
  • Loading branch information
gforcada committed Jul 5, 2016
1 parent ae74f1c commit 574c886
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 14 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.3.6 (2016-05-12)
Expand Down
5 changes: 2 additions & 3 deletions plone/app/users/browser/account.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
from zope.component import getMultiAdapter
from zope.component import getUtility
from zope.event import notify
from zope.interface import implements
from zope.interface import implementer


MESSAGE_EMAIL_CANNOT_CHANGE = \
Expand Down Expand Up @@ -127,10 +127,9 @@ def set_portrait(self, value):
portrait = property(get_portrait, set_portrait)


@implementer(IAccountPanelForm)
class AccountPanelForm(AutoExtensibleForm, form.Form):
"""A simple form to be used as a basis for account panel screens."""

implements(IAccountPanelForm)
schema = IAccountPanelForm
template = ViewPageTemplateFile('account-panel.pt')
enableCSRFProtection = True
Expand Down
6 changes: 3 additions & 3 deletions plone/app/users/browser/schemaeditor.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from zope.component import getGlobalSiteManager
from zope.component.hooks import getSite
from zope.annotation.interfaces import IAnnotations
from zope.interface import Interface, implements
from zope.interface import Interface, implementer

from Products.CMFPlone import PloneMessageFactory as _
from Products.CMFPlone.interfaces import IPloneSiteRoot
Expand Down Expand Up @@ -92,8 +92,8 @@ class SchemaListingPage(FormWrapper):
index = ViewPageTemplateFile('schema_layout.pt')


@implementer(IMemberSchemaContext)
class MemberSchemaContext(SchemaContext):
implements(IMemberSchemaContext)

label = _(u"Edit Member Form Fields")

Expand Down Expand Up @@ -181,10 +181,10 @@ def get_ttw_edited_schema():
return ''


@implementer(IFieldMetadataHandler)
class UsersMetadataSchemaExporter(object):
"""Support the security: namespace in model definitions.
"""
implements(IFieldMetadataHandler)
namespace = ns = USERS_NAMESPACE
prefix = USERS_PREFIX
if_attrs = (
Expand Down
4 changes: 2 additions & 2 deletions plone/app/users/field_extender.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from zope.interface import Interface, implements
from zope.interface import Interface, implementer
from zope import schema

from zope.component import adapts
Expand Down Expand Up @@ -57,8 +57,8 @@ def _set_forms(self, value):
forms = property(_get_forms, _set_forms)


@implementer(IFieldMetadataHandler)
class UserFormSelectionMetadata(object):
implements(IFieldMetadataHandler)

namespace = USERS_NAMESPACE
prefix = USERS_PREFIX
Expand Down
4 changes: 2 additions & 2 deletions plone/app/users/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from Products.CMFPlone import PloneMessageFactory as _
from zope import schema
from zope.component import getUtility
from zope.interface import Interface, implements, implementer
from zope.interface import Interface, implementer, implementer
from ZTUtils import make_query
from plone.formwidget.namedfile.widget import NamedImageWidget
from plone.namedfile.interfaces import INamedImageField
Expand Down Expand Up @@ -47,8 +47,8 @@ class ProtectedEmail(Email):
pass


@implementer(IFieldFactory)
class NotEditableFieldFactory(FieldFactory):
implements(IFieldFactory)

title = _(u'(protected)')

Expand Down
6 changes: 3 additions & 3 deletions plone/app/users/vocabularies.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from Products.CMFCore.utils import getToolByName
from Products.CMFPlone.utils import normalizeString
from Products.CMFPlone.utils import safe_unicode
from zope.interface import implements
from zope.interface import implementer
from zope.schema import getFieldNames
from zope.schema.interfaces import IVocabularyFactory
from zope.schema.vocabulary import SimpleVocabulary
Expand All @@ -19,6 +19,7 @@
JOIN_CONST = ['username', 'password', 'email', 'mail_me']


@implementer(IVocabularyFactory)
class UserRegistrationFieldsVocabulary(object):
"""Returns list of fields available for registration form.
Expand All @@ -45,7 +46,6 @@ class UserRegistrationFieldsVocabulary(object):
('email', 'email', 'email')
"""
implements(IVocabularyFactory)

def __call__(self, context):
# default list of Registration Form fields
Expand All @@ -62,6 +62,7 @@ def __call__(self, context):
UserRegistrationFieldsVocabularyFactory = UserRegistrationFieldsVocabulary()


@implementer(IVocabularyFactory)
class GroupIdVocabulary(object):
"""
Return vocab of groups to add new user to.
Expand Down Expand Up @@ -92,7 +93,6 @@ class GroupIdVocabulary(object):
[u'Group Title (fancygroup)', u'Reviewers', u'Site Administrators']
"""
implements(IVocabularyFactory)

def __call__(self, context):
site = getSite()
Expand Down

0 comments on commit 574c886

Please sign in to comment.