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 498969c commit 08565f3
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 21 deletions.
2 changes: 2 additions & 0 deletions CHANGES.rst
Expand Up @@ -36,6 +36,8 @@ Fixes:
- Miscellaneous minor bugfixes and documentation improvements.
[adaugherity]

- Use zope.interface decorator.
[gforcada]

1.3.2 (2015-03-02)
------------------
Expand Down
6 changes: 3 additions & 3 deletions plone/app/ldap/browser/schema.py
@@ -1,6 +1,6 @@
from zope.component import adapts
from zope.component import getUtility
from zope.interface import implements
from zope.interface import implementer
from zope.traversing.interfaces import ITraversable
from zope.publisher.interfaces.browser import IBrowserRequest
from zope.formlib.form import FormFields
Expand All @@ -16,8 +16,8 @@
from plone.app.ldap.browser.baseform import Adding


@implementer(IPropertyAdding)
class PropertyAdding(Adding):
implements(IPropertyAdding)

def add(self, content):
"""Add the property to the schema
Expand Down Expand Up @@ -57,10 +57,10 @@ class PropertyEditForm(LDAPEditForm):
fieldset = "schema"


@implementer(ITraversable)
class SchemaNamespace(object):
"""LDAP schema traversing.
"""
implements(ITraversable)
adapts(ISiteRoot, IBrowserRequest)

def __init__(self, context, request=None):
Expand Down
6 changes: 3 additions & 3 deletions plone/app/ldap/browser/server.py
Expand Up @@ -13,14 +13,14 @@
from zope.event import notify
from zope.formlib.form import FormFields
from zope.formlib.form import applyChanges
from zope.interface import implements
from zope.interface import implementer
from zope.lifecycleevent import ObjectCreatedEvent
from zope.publisher.interfaces.browser import IBrowserRequest
from zope.traversing.interfaces import ITraversable


@implementer(IServerAdding)
class ServerAdding(Adding):
implements(IServerAdding)

def add(self, content):
"""Add the server to the context
Expand Down Expand Up @@ -62,13 +62,13 @@ class ServerEditForm(LDAPEditForm):
fieldset = "servers"


@implementer(ITraversable)
class ServerNamespace(object):
"""LDAP server traversing.
Traversing to portal/++ldapserver++id will traverse to the ldap server and
return it in the current context, acquisition-wrapped.
"""
implements(ITraversable)
adapts(ISiteRoot, IBrowserRequest)

def __init__(self, context, request=None):
Expand Down
4 changes: 2 additions & 2 deletions plone/app/ldap/engine/schema.py
@@ -1,10 +1,10 @@
from OFS.SimpleItem import SimpleItem
from zope.interface import implements
from zope.interface import implementer
from plone.app.ldap.engine.interfaces import ILDAPProperty


@implementer(ILDAPProperty)
class LDAPProperty(SimpleItem):
implements(ILDAPProperty)

__name__ = None
__parent__ = None
Expand Down
4 changes: 2 additions & 2 deletions plone/app/ldap/engine/server.py
@@ -1,10 +1,10 @@
from OFS.SimpleItem import SimpleItem
from zope.interface import implements
from zope.interface import implementer
from plone.app.ldap.engine.interfaces import ILDAPServer


@implementer(ILDAPServer)
class LDAPServer(SimpleItem):
implements(ILDAPServer)

__name__ = None
__parent__ = None
Expand Down
8 changes: 4 additions & 4 deletions plone/app/ldap/engine/storage.py
@@ -1,4 +1,4 @@
from zope.interface import implements
from zope.interface import implementer
from zope.container.ordered import OrderedContainer
from zope.container.interfaces import INameChooser
from plone.app.ldap.engine.interfaces import ILDAPServerStorage
Expand All @@ -9,8 +9,8 @@
from plone.app.ldap.engine.schema import LDAPProperty


@implementer(ILDAPConfiguration)
class LDAPConfiguration(OrderedContainer):
implements(ILDAPConfiguration)

ldap_type = u"LDAP"
rdn_attribute = "uid"
Expand Down Expand Up @@ -65,13 +65,13 @@ def addItem(self, item):
self[item_id]=item


@implementer(ILDAPServerStorage)
class LDAPServerStorage(LDAPContainer):
"""A container for LDAP servers.
"""
implements(ILDAPServerStorage)


@implementer(ILDAPSchema)
class LDAPSchema(LDAPContainer):
"""A container for LDAP properties.
"""
implements(ILDAPSchema)
14 changes: 7 additions & 7 deletions plone/app/ldap/engine/vocabulary.py
@@ -1,4 +1,4 @@
from zope.interface import implements
from zope.interface import implementer
from zope.schema.vocabulary import SimpleVocabulary
from zope.schema.vocabulary import SimpleTerm
from zope.component import getUtility
Expand All @@ -8,10 +8,10 @@
from zope.schema.interfaces import IVocabularyFactory


@implementer(IVocabularyFactory)
class LDAPServerTypeVocabulary(object):
"""Vocabulary factory for LDAP server types.
"""
implements(IVocabularyFactory)

def __call__(self, context):
return SimpleVocabulary([
Expand All @@ -22,10 +22,10 @@ def __call__(self, context):
LDAPServerTypeVocabularyFactory = LDAPServerTypeVocabulary()


@implementer(IVocabularyFactory)
class LDAPConnectionTypeVocabulary(object):
"""Vocabulary factory for LDAP connection types.
"""
implements(IVocabularyFactory)

def __call__(self, context):
return SimpleVocabulary([
Expand All @@ -37,10 +37,10 @@ def __call__(self, context):
LDAPConnectionTypeVocabularyFactory = LDAPConnectionTypeVocabulary()


@implementer(IVocabularyFactory)
class LDAPScopeVocabulary(object):
"""Vocabulary factory for LDAP search scopes.
"""
implements(IVocabularyFactory)

def __call__(self, context):
return SimpleVocabulary([
Expand All @@ -51,10 +51,10 @@ def __call__(self, context):
LDAPScopeVocabularyFactory = LDAPScopeVocabulary()


@implementer(IVocabularyFactory)
class LDAPAttributesVocabulary(object):
"""Vocabulary factory for LDAP attributes.
"""
implements(IVocabularyFactory)

def __call__(self, context):
config=getUtility(ILDAPConfiguration)
Expand All @@ -64,10 +64,10 @@ def __call__(self, context):
LDAPAttributesVocabularyFactory = LDAPAttributesVocabulary()


@implementer(IVocabularyFactory)
class LDAPSingleValueAttributesVocabulary(object):
"""Vocabulary factory for LDAP attributes.
"""
implements(IVocabularyFactory)

def __call__(self, context):
config=getUtility(ILDAPConfiguration)
Expand All @@ -78,10 +78,10 @@ def __call__(self, context):
LDAPSingleValueAttributesVocabularyFactory = LDAPSingleValueAttributesVocabulary()


@implementer(IVocabularyFactory)
class LDAPPasswordEncryptionVocabulary(object):
"""Vocabulary factory for LDAP Password encryption.
"""
implements(IVocabularyFactory)

def __call__(self, context):
return SimpleVocabulary([
Expand Down

0 comments on commit 08565f3

Please sign in to comment.