Move viewlets to browser package, use a layer instead of an overrides.zcml. Also add ++comment++ namespace, though it may require refactoring
svn path=/plone.app.discussion/trunk/; revision=27055
This commit is contained in:
parent
895105b2c9
commit
edf956f01c
@ -3,5 +3,19 @@
|
||||
xmlns:browser="http://namespaces.zope.org/browser"
|
||||
i18n_domain="plone.app.discussion">
|
||||
|
||||
<!-- Traversal adapter -->
|
||||
<adapter factory=".traversal.ConversationNamespace" name="comment" />
|
||||
|
||||
<!-- Comments viewlet -->
|
||||
<browser:viewlet
|
||||
name="plone.comments"
|
||||
for="Products.CMFCore.interfaces.IContentish"
|
||||
layer="..interfaces.IDiscussionLayer"
|
||||
view="plone.app.layout.globals.interfaces.IViewView"
|
||||
manager="plone.app.layout.viewlets.interfaces.IBelowContent"
|
||||
template="comments.pt"
|
||||
class=".comments.CommentsViewlet"
|
||||
permission="zope2.View"
|
||||
/>
|
||||
|
||||
</configure>
|
||||
|
@ -3,3 +3,28 @@ IDiscussion container for the context, from which traversal will continue
|
||||
into an actual comment object.
|
||||
"""
|
||||
|
||||
from zope.interface import Interface, implements
|
||||
from zope.component import adapts
|
||||
|
||||
from zope.traversing.interfaces import ITraversable, TraversalError
|
||||
from zope.publisher.interfaces.browser import IBrowserRequest
|
||||
|
||||
from plone.app.discussion.interfaces import IConversation
|
||||
|
||||
class ConversationNamespace(object):
|
||||
"""Allow traversal into a conversation
|
||||
"""
|
||||
implements(ITraversable)
|
||||
adapts(Interface, IBrowserRequest)
|
||||
|
||||
def __init__(self, context, request=None):
|
||||
self.context = context
|
||||
self.request = request
|
||||
|
||||
def traverse(self, name, ignore):
|
||||
|
||||
conversation = IConversation(self.context, None)
|
||||
if conversation is None:
|
||||
raise TraversalError('++comment++')
|
||||
|
||||
return conversation.__of__(self.context)
|
||||
|
@ -5,7 +5,6 @@
|
||||
|
||||
<include file="permissions.zcml" />
|
||||
<include package=".browser" />
|
||||
<include package=".viewlets" />
|
||||
|
||||
<!-- Register the installation GenericSetup extension profile -->
|
||||
<genericsetup:registerProfile
|
||||
|
@ -16,7 +16,8 @@ from persistent import Persistent
|
||||
|
||||
from zope.interface import implements, implementer
|
||||
from zope.component import adapts, adapter
|
||||
from zope.annotation.interfaces import IAnnotations
|
||||
|
||||
from zope.annotation.interfaces import IAnnotations, IAnnotatable
|
||||
|
||||
from zope.event import notify
|
||||
|
||||
@ -33,8 +34,6 @@ from zope.app.container.contained import ContainerModifiedEvent
|
||||
from zope.app.container.contained import ObjectAddedEvent
|
||||
from zope.app.container.contained import ObjectRemovedEvent
|
||||
|
||||
from zope.annotation.interfaces import IAnnotatable
|
||||
|
||||
from BTrees.OIBTree import OIBTree
|
||||
|
||||
try:
|
||||
@ -59,7 +58,7 @@ class Conversation(Traversable, Persistent, Explicit):
|
||||
|
||||
implements(IConversation)
|
||||
|
||||
def __init__(self, id="++comments++"):
|
||||
def __init__(self, id="++comment++"):
|
||||
self.id = id
|
||||
|
||||
# username -> count of comments; key is removed when count reaches 0
|
||||
|
@ -158,3 +158,7 @@ class ICommentingTool(Interface):
|
||||
def searchResults(REQUEST=None, **kw):
|
||||
"""Perform a search over all indexed comments.
|
||||
"""
|
||||
|
||||
class IDiscussionLayer(Interface):
|
||||
"""Request marker installed via browserlayer.xml.
|
||||
"""
|
@ -1,6 +0,0 @@
|
||||
<configure xmlns="http://namespaces.zope.org/zope">
|
||||
|
||||
<include
|
||||
file="viewlets/overrides.zcml" />
|
||||
|
||||
</configure>
|
6
plone/app/discussion/profiles/default/browserlayer.xml
Normal file
6
plone/app/discussion/profiles/default/browserlayer.xml
Normal file
@ -0,0 +1,6 @@
|
||||
<layers>
|
||||
<layer
|
||||
name="plone.app.discussion"
|
||||
interface="plone.app.discussion.interfaces.IDiscussionLayer"
|
||||
/>
|
||||
</layers>
|
@ -34,6 +34,13 @@ class CommentTest(PloneTestCase):
|
||||
|
||||
def test_traversal(self):
|
||||
# make sure comments are traversable, have an id, absolute_url and physical path
|
||||
|
||||
# XXX - traversal doesn't work without a name?
|
||||
conversation = self.portal.doc1.restrictedTraverse('++comment++1')
|
||||
self.assert_(IConversation.providedBy(conversation))
|
||||
|
||||
# TODO: Test adding comments, traversing to them
|
||||
|
||||
pass
|
||||
|
||||
def test_workflow(self):
|
||||
|
@ -1,3 +0,0 @@
|
||||
<configure xmlns="http://namespaces.zope.org/zope">
|
||||
|
||||
</configure>
|
@ -1,14 +0,0 @@
|
||||
<configure xmlns="http://namespaces.zope.org/zope"
|
||||
xmlns:browser="http://namespaces.zope.org/browser">
|
||||
|
||||
<!-- comments viewlet -->
|
||||
<browser:viewlet
|
||||
name="plone.comments"
|
||||
for="Products.CMFCore.interfaces.IContentish"
|
||||
manager="plone.app.layout.viewlets.interfaces.IBelowContent"
|
||||
view="plone.app.layout.globals.interfaces.IViewView"
|
||||
template="comments.pt"
|
||||
class="plone.app.discussion.viewlets.comments.CommentsViewlet"
|
||||
permission="zope2.View" />
|
||||
|
||||
</configure>
|
Loading…
Reference in New Issue
Block a user