From 71ed7077948698663aeab6c22f1bf997e1f3b250 Mon Sep 17 00:00:00 2001 From: Hanno Schlichting Date: Fri, 16 Oct 2009 00:42:08 +0000 Subject: [PATCH] Get this running again for the most part under Plone 4.0 - the main trick was probably to use the new CMFCatalogAware class. Removed collective.testcaselayer dependency, as that broke totally. There's some test failures left, but indexing works in general. Maybe the custom indexing event handlers aren't all required anymore. The title_or_id test failure looks like there's an infinite loop in the __parent__ pointers never reaching the actual content object. This change breaks Plone 3.x compatibility for the moment. svn path=/plone.app.discussion/trunk/; revision=30629 --- plone/app/discussion/PRINCIPLES.txt | 2 +- plone/app/discussion/catalog.py | 3 +-- plone/app/discussion/comment.py | 16 ++++------------ plone/app/discussion/configure.zcml | 10 +++++----- plone/app/discussion/conversation.py | 8 ++++---- plone/app/discussion/tests/layer.py | 27 ++++++++++++++++++++------- setup.py | 5 +++-- 7 files changed, 38 insertions(+), 33 deletions(-) diff --git a/plone/app/discussion/PRINCIPLES.txt b/plone/app/discussion/PRINCIPLES.txt index 11b4679..d7ab048 100644 --- a/plone/app/discussion/PRINCIPLES.txt +++ b/plone/app/discussion/PRINCIPLES.txt @@ -55,7 +55,7 @@ plone.app.discussion. Ids can be based on the creation date. Discussion items send events - The usual zope.lifecycleevent and zope.app.container events should be + The usual zope.lifecycleevent and zope.container events should be fired when discussion items are added, removed, or modified. Outstanding questions diff --git a/plone/app/discussion/catalog.py b/plone/app/discussion/catalog.py index 8651255..3c3a141 100644 --- a/plone/app/discussion/catalog.py +++ b/plone/app/discussion/catalog.py @@ -4,7 +4,7 @@ indexes with values based on the IComment interface. Also provide event handlers to actually catalog the comments. """ -from string import split, join +from string import join from DateTime import DateTime @@ -15,7 +15,6 @@ from Products.ZCatalog.interfaces import IZCatalog from plone.app.discussion.interfaces import IConversation, IComment from plone.indexer import indexer -from plone.indexer.interfaces import IIndexer MAX_DESCRIPTION=25 diff --git a/plone/app/discussion/comment.py b/plone/app/discussion/comment.py index c6bb031..25a1239 100644 --- a/plone/app/discussion/comment.py +++ b/plone/app/discussion/comment.py @@ -12,9 +12,12 @@ from AccessControl.Owned import Owned from plone.app.discussion.interfaces import IComment from Products.CMFCore.DynamicType import DynamicType +from Products.CMFCore.CMFCatalogAware import CMFCatalogAware +from Products.CMFCore.CMFCatalogAware import WorkflowAware from Products.CMFCore.utils import getToolByName -class Comment(DynamicType, Traversable, RoleManager, Owned, Implicit): +class Comment(CMFCatalogAware, WorkflowAware, DynamicType, + Traversable, RoleManager, Owned, Implicit): """A comment. This object attempts to be as lightweight as possible. We implement a @@ -84,17 +87,6 @@ class Comment(DynamicType, Traversable, RoleManager, Owned, Implicit): """ return self.portal_type - # CMF's event handlers assume any IDynamicType has these :( - - def opaqueItems(self): - return [] - - def opaqueIds(self): - return [] - - def opaqueValues(self): - return [] - CommentFactory = Factory(Comment) def notify_workflow(obj, event): diff --git a/plone/app/discussion/configure.zcml b/plone/app/discussion/configure.zcml index a8012cf..5abd83f 100644 --- a/plone/app/discussion/configure.zcml +++ b/plone/app/discussion/configure.zcml @@ -58,31 +58,31 @@ diff --git a/plone/app/discussion/conversation.py b/plone/app/discussion/conversation.py index de4d156..2d470ea 100644 --- a/plone/app/discussion/conversation.py +++ b/plone/app/discussion/conversation.py @@ -16,7 +16,7 @@ from persistent import Persistent from plone.registry.interfaces import IRegistry -from zope.app.component.hooks import getSite +from zope.site.hooks import getSite from zope.interface import implements, implementer from zope.component import adapts, adapter, queryUtility @@ -38,10 +38,10 @@ from Products.CMFCore.interfaces import IFolderish from Products.CMFPlone.interfaces import IPloneSiteRoot, INonStructuralFolder -from zope.app.container.contained import ContainerModifiedEvent +from zope.container.contained import ContainerModifiedEvent -from zope.app.container.contained import ObjectAddedEvent -from zope.app.container.contained import ObjectRemovedEvent +from zope.lifecycleevent import ObjectAddedEvent +from zope.lifecycleevent import ObjectRemovedEvent from BTrees.OIBTree import OIBTree diff --git a/plone/app/discussion/tests/layer.py b/plone/app/discussion/tests/layer.py index 081fa2a..718b7c7 100644 --- a/plone/app/discussion/tests/layer.py +++ b/plone/app/discussion/tests/layer.py @@ -1,12 +1,25 @@ +from Testing import ZopeTestCase as ztc + from Products.PloneTestCase import ptc -import collective.testcaselayer.ptc +from Products.PloneTestCase import layer +from Products.Five import zcml +from Products.Five import fiveconfigure -ptc.setupPloneSite() +ptc.setupPloneSite( + extension_profiles=('plone.app.discussion:default', ) +) -class Layer(collective.testcaselayer.ptc.BasePTCLayer): - """Install plone.app.discussion""" +class DiscussionLayer(layer.PloneSite): + """Configure plone.app.discussion""" - def afterSetUp(self): - self.addProfile('plone.app.discussion:default') + @classmethod + def setUp(cls): + fiveconfigure.debug_mode = True + import plone.app.discussion + zcml.load_config("configure.zcml", plone.app.discussion) + fiveconfigure.debug_mode = False + ztc.installPackage("plone.app.discussion", quiet=1) -DiscussionLayer = Layer([collective.testcaselayer.ptc.ptc_layer]) \ No newline at end of file + @classmethod + def tearDown(cls): + pass diff --git a/setup.py b/setup.py index 8f08669..48add53 100644 --- a/setup.py +++ b/setup.py @@ -26,7 +26,6 @@ setup(name='plone.app.discussion', install_requires=[ 'setuptools', 'collective.autopermission', - 'collective.testcaselayer', 'plone.app.registry', 'plone.indexer', 'plone.registry', @@ -38,7 +37,9 @@ setup(name='plone.app.discussion', 'zope.component', 'zope.annotation', 'zope.event', - 'zope.app.container', # XXX: eventually should change to zope.container + 'zope.container', + 'zope.lifecycleevent', + 'zope.site', ], entry_points=""" [z3c.autoinclude.plugin]