some code-analysis reclamations fixed.

code-analysis OK up to: T100, S100, S101, C815, C812
This commit is contained in:
Katja Süss 2017-07-29 11:35:15 +02:00
parent 100690ccdf
commit b08852baa0
5 changed files with 8 additions and 12 deletions

View File

@ -47,7 +47,7 @@ comment form with the "website" field::
from zope import schema from zope import schema
from zope.annotation import factory from zope.annotation import factory
from zope.component import adapts from zope.component import adapter
from zope.interface import Interface from zope.interface import Interface
from zope.publisher.interfaces.browser import IDefaultBrowserLayer from zope.publisher.interfaces.browser import IDefaultBrowserLayer
@ -61,9 +61,9 @@ comment form with the "website" field::
website = schema.TextLine(title=u"Website", required=False) website = schema.TextLine(title=u"Website", required=False)
# Persistent class that implements the ICommentExtenderFields interface # Persistent class that implements the ICommentExtenderFields interface
@adapter(Comment)
class CommentExtenderFields(Persistent): class CommentExtenderFields(Persistent):
interface.implements(ICommentExtenderFields) interface.implements(ICommentExtenderFields)
adapts(Comment)
website = u"" website = u""
# CommentExtenderFields factory # CommentExtenderFields factory
@ -71,9 +71,8 @@ comment form with the "website" field::
# Extending the comment form with the fields defined in the # Extending the comment form with the fields defined in the
# ICommentExtenderFields interface. # ICommentExtenderFields interface.
@adapter(Interface, IDefaultBrowserLayer, CommentForm)
class CommentExtender(extensible.FormExtender): class CommentExtender(extensible.FormExtender):
adapts(Interface, IDefaultBrowserLayer, CommentForm)
fields = Fields(ICommentExtenderFields) fields = Fields(ICommentExtenderFields)
def __init__(self, context, request, form): def __init__(self, context, request, form):

View File

@ -13,8 +13,8 @@ from zope.traversing.interfaces import ITraversable
from zope.traversing.interfaces import TraversalError from zope.traversing.interfaces import TraversalError
@adapter(Interface, IBrowserRequest)
@implementer(ITraversable) @implementer(ITraversable)
@adapter(Interface, IBrowserRequest)
class ConversationNamespace(object): class ConversationNamespace(object):
"""Allow traversal into a conversation via a ++conversation++name """Allow traversal into a conversation via a ++conversation++name
namespace. The name is the name of an adapter from context to namespace. The name is the name of an adapter from context to

View File

@ -32,8 +32,8 @@ except ImportError:
pass pass
@adapter(Interface, IDiscussionLayer, Interface, IField, Interface)
@implementer(IValidator) @implementer(IValidator)
@adapter(Interface, IDiscussionLayer, Interface, IField, Interface)
class CaptchaValidator(validator.SimpleFieldValidator): class CaptchaValidator(validator.SimpleFieldValidator):
# Object, Request, Form, Field, Widget, # Object, Request, Form, Field, Widget,
# We adapt the CaptchaValidator class to all form fields (IField) # We adapt the CaptchaValidator class to all form fields (IField)

View File

@ -77,10 +77,7 @@ def creator(object):
@indexer(IComment) @indexer(IComment)
def description(object): def description(object):
# Return the first 25 words of the comment text and append ' [...]' # Return the first 25 words of the comment text and append ' [...]'
text = join( text = join(object.getText(targetMimetype='text/plain').split()[:MAX_DESCRIPTION])
object.getText(targetMimetype='text/plain')
.split()[:MAX_DESCRIPTION]
)
if len(object.getText().split()) > 25: if len(object.getText().split()) > 25:
text += ' [...]' text += ' [...]'
return text return text

View File

@ -324,8 +324,8 @@ else:
return conversationAdapterFactory(content) return conversationAdapterFactory(content)
@adapter(Conversation) # relies on implementation details
@implementer(IReplies) @implementer(IReplies)
@adapter(Conversation) # relies on implementation details
class ConversationReplies(object): class ConversationReplies(object):
"""An IReplies adapter for conversations. """An IReplies adapter for conversations.
@ -400,8 +400,8 @@ class ConversationReplies(object):
return self.conversation._children.get(self.comment_id, LLSet()) return self.conversation._children.get(self.comment_id, LLSet())
@adapter(Comment)
@implementer(IReplies) @implementer(IReplies)
@adapter(Comment)
class CommentReplies(ConversationReplies): class CommentReplies(ConversationReplies):
"""An IReplies adapter for comments. """An IReplies adapter for comments.