Use zope.interface decorator

This not only makes code more pleasent to read,
but also makes the code python 3 compatible
(while maintaining python 2 compatibility).
This commit is contained in:
Gil Forcada
2016-07-05 23:12:08 +02:00
parent 3619419df4
commit d5e7afcd23
8 changed files with 19 additions and 25 deletions
+1 -1
View File
@@ -18,10 +18,10 @@ from zope.interface import Interface
from zope.publisher.interfaces.browser import IDefaultBrowserLayer
@interface.implementer(ICaptcha)
class Captcha(Persistent):
"""Captcha input field.
"""
interface.implements(ICaptcha)
adapts(Comment)
captcha = u""
+2 -3
View File
@@ -6,13 +6,14 @@ into an actual comment object.
from plone.app.discussion.interfaces import IConversation
from zope.component import adapts
from zope.component import queryAdapter
from zope.interface import implements
from zope.interface import implementer
from zope.interface import Interface
from zope.publisher.interfaces.browser import IBrowserRequest
from zope.traversing.interfaces import ITraversable
from zope.traversing.interfaces import TraversalError
@implementer(ITraversable)
class ConversationNamespace(object):
"""Allow traversal into a conversation via a ++conversation++name
namespace. The name is the name of an adapter from context to
@@ -20,8 +21,6 @@ class ConversationNamespace(object):
(unnamed) adapter. This is to work around a bug in OFS.Traversable which
does not allow traversal to namespaces with an empty string name.
"""
implements(ITraversable)
adapts(Interface, IBrowserRequest)
def __init__(self, context, request=None):
+2 -2
View File
@@ -11,7 +11,7 @@ from z3c.form.interfaces import IValidator
from zope.component import adapts
from zope.component import getMultiAdapter
from zope.component import queryUtility
from zope.interface import implements
from zope.interface import implementer
from zope.interface import Interface
from zope.schema.interfaces import IField
@@ -32,8 +32,8 @@ except ImportError:
pass
@implementer(IValidator)
class CaptchaValidator(validator.SimpleFieldValidator):
implements(IValidator)
adapts(Interface, IDiscussionLayer, Interface, IField, Interface)
# Object, Request, Form, Field, Widget,
# We adapt the CaptchaValidator class to all form fields (IField)