From edf956f01cbc9477a1844a31cabe77f1ae8c3f54 Mon Sep 17 00:00:00 2001 From: Martin Aspeli Date: Sat, 23 May 2009 04:55:06 +0000 Subject: [PATCH] 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 --- .../{viewlets => browser}/comments.pt | 0 .../{viewlets => browser}/comments.py | 0 plone/app/discussion/browser/configure.zcml | 14 +++++++++++ plone/app/discussion/browser/traversal.py | 25 +++++++++++++++++++ plone/app/discussion/configure.zcml | 1 - plone/app/discussion/conversation.py | 7 +++--- plone/app/discussion/interfaces.py | 4 +++ plone/app/discussion/overrides.zcml | 6 ----- .../profiles/default/browserlayer.xml | 6 +++++ plone/app/discussion/tests/test_comment.py | 7 ++++++ .../app/discussion/tests/test_conversation.py | 2 +- plone/app/discussion/viewlets/__init__.py | 0 plone/app/discussion/viewlets/configure.zcml | 3 --- plone/app/discussion/viewlets/overrides.zcml | 14 ----------- 14 files changed, 60 insertions(+), 29 deletions(-) rename plone/app/discussion/{viewlets => browser}/comments.pt (100%) rename plone/app/discussion/{viewlets => browser}/comments.py (100%) delete mode 100644 plone/app/discussion/overrides.zcml create mode 100644 plone/app/discussion/profiles/default/browserlayer.xml delete mode 100644 plone/app/discussion/viewlets/__init__.py delete mode 100644 plone/app/discussion/viewlets/configure.zcml delete mode 100644 plone/app/discussion/viewlets/overrides.zcml diff --git a/plone/app/discussion/viewlets/comments.pt b/plone/app/discussion/browser/comments.pt similarity index 100% rename from plone/app/discussion/viewlets/comments.pt rename to plone/app/discussion/browser/comments.pt diff --git a/plone/app/discussion/viewlets/comments.py b/plone/app/discussion/browser/comments.py similarity index 100% rename from plone/app/discussion/viewlets/comments.py rename to plone/app/discussion/browser/comments.py diff --git a/plone/app/discussion/browser/configure.zcml b/plone/app/discussion/browser/configure.zcml index 0a55cb2..56a10e2 100644 --- a/plone/app/discussion/browser/configure.zcml +++ b/plone/app/discussion/browser/configure.zcml @@ -2,6 +2,20 @@ xmlns="http://namespaces.zope.org/zope" xmlns:browser="http://namespaces.zope.org/browser" i18n_domain="plone.app.discussion"> + + + + + diff --git a/plone/app/discussion/browser/traversal.py b/plone/app/discussion/browser/traversal.py index ae3a38c..930a6d0 100644 --- a/plone/app/discussion/browser/traversal.py +++ b/plone/app/discussion/browser/traversal.py @@ -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) diff --git a/plone/app/discussion/configure.zcml b/plone/app/discussion/configure.zcml index b9fee18..931a3f7 100644 --- a/plone/app/discussion/configure.zcml +++ b/plone/app/discussion/configure.zcml @@ -5,7 +5,6 @@ - count of comments; key is removed when count reaches 0 diff --git a/plone/app/discussion/interfaces.py b/plone/app/discussion/interfaces.py index a1053c9..9c98a23 100644 --- a/plone/app/discussion/interfaces.py +++ b/plone/app/discussion/interfaces.py @@ -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. + """ \ No newline at end of file diff --git a/plone/app/discussion/overrides.zcml b/plone/app/discussion/overrides.zcml deleted file mode 100644 index f556b83..0000000 --- a/plone/app/discussion/overrides.zcml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - \ No newline at end of file diff --git a/plone/app/discussion/profiles/default/browserlayer.xml b/plone/app/discussion/profiles/default/browserlayer.xml new file mode 100644 index 0000000..c64858b --- /dev/null +++ b/plone/app/discussion/profiles/default/browserlayer.xml @@ -0,0 +1,6 @@ + + + \ No newline at end of file diff --git a/plone/app/discussion/tests/test_comment.py b/plone/app/discussion/tests/test_comment.py index aed3445..bd5e905 100644 --- a/plone/app/discussion/tests/test_comment.py +++ b/plone/app/discussion/tests/test_comment.py @@ -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): diff --git a/plone/app/discussion/tests/test_conversation.py b/plone/app/discussion/tests/test_conversation.py index 3e13518..a3ba04f 100644 --- a/plone/app/discussion/tests/test_conversation.py +++ b/plone/app/discussion/tests/test_conversation.py @@ -96,7 +96,7 @@ class ConversationTest(PloneTestCase): pass def test_get_comments_batched(self): - pass + pass def test_get_threads(self): pass diff --git a/plone/app/discussion/viewlets/__init__.py b/plone/app/discussion/viewlets/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/plone/app/discussion/viewlets/configure.zcml b/plone/app/discussion/viewlets/configure.zcml deleted file mode 100644 index 9541b1a..0000000 --- a/plone/app/discussion/viewlets/configure.zcml +++ /dev/null @@ -1,3 +0,0 @@ - - - \ No newline at end of file diff --git a/plone/app/discussion/viewlets/overrides.zcml b/plone/app/discussion/viewlets/overrides.zcml deleted file mode 100644 index aa7670f..0000000 --- a/plone/app/discussion/viewlets/overrides.zcml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - \ No newline at end of file