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
+3 -7
View File
@@ -34,7 +34,6 @@ from zope.component import adapts
from zope.container.contained import ContainerModifiedEvent
from zope.event import notify
from zope.interface import implementer
from zope.interface import implements
from zope.lifecycleevent import ObjectAddedEvent
from zope.lifecycleevent import ObjectCreatedEvent
from zope.lifecycleevent import ObjectRemovedEvent
@@ -42,6 +41,7 @@ from zope.lifecycleevent import ObjectRemovedEvent
import time
@implementer(IConversation, IHideFromBreadcrumbs)
class Conversation(Traversable, Persistent, Explicit):
"""A conversation is a container for all comments on a content object.
@@ -49,8 +49,6 @@ class Conversation(Traversable, Persistent, Explicit):
comment lookup.
"""
implements(IConversation, IHideFromBreadcrumbs)
__allow_access_to_unprotected_subobjects__ = True
def __init__(self, id='++conversation++default'):
@@ -327,13 +325,12 @@ else:
return conversationAdapterFactory(content)
@implementer(IReplies)
class ConversationReplies(object):
"""An IReplies adapter for conversations.
This makes it easy to work with top-level comments.
"""
implements(IReplies)
adapts(Conversation) # relies on implementation details
def __init__(self, context):
@@ -404,14 +401,13 @@ class ConversationReplies(object):
return self.conversation._children.get(self.comment_id, LLSet())
@implementer(IReplies)
class CommentReplies(ConversationReplies):
"""An IReplies adapter for comments.
This makes it easy to work with replies to specific comments.
"""
implements(IReplies)
# depends on implementation details of conversation
# most likely, anyone writing a different type of Conversation will also
# have a different type of Comment