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
This commit is contained in:
Hanno Schlichting 2009-10-16 00:42:08 +00:00
parent c19feeab6e
commit 71ed707794
7 changed files with 38 additions and 33 deletions

View File

@ -55,7 +55,7 @@ plone.app.discussion.
Ids can be based on the creation date. Ids can be based on the creation date.
Discussion items send events 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. fired when discussion items are added, removed, or modified.
Outstanding questions Outstanding questions

View File

@ -4,7 +4,7 @@ indexes with values based on the IComment interface.
Also provide event handlers to actually catalog the comments. Also provide event handlers to actually catalog the comments.
""" """
from string import split, join from string import join
from DateTime import DateTime from DateTime import DateTime
@ -15,7 +15,6 @@ from Products.ZCatalog.interfaces import IZCatalog
from plone.app.discussion.interfaces import IConversation, IComment from plone.app.discussion.interfaces import IConversation, IComment
from plone.indexer import indexer from plone.indexer import indexer
from plone.indexer.interfaces import IIndexer
MAX_DESCRIPTION=25 MAX_DESCRIPTION=25

View File

@ -12,9 +12,12 @@ from AccessControl.Owned import Owned
from plone.app.discussion.interfaces import IComment from plone.app.discussion.interfaces import IComment
from Products.CMFCore.DynamicType import DynamicType from Products.CMFCore.DynamicType import DynamicType
from Products.CMFCore.CMFCatalogAware import CMFCatalogAware
from Products.CMFCore.CMFCatalogAware import WorkflowAware
from Products.CMFCore.utils import getToolByName from Products.CMFCore.utils import getToolByName
class Comment(DynamicType, Traversable, RoleManager, Owned, Implicit): class Comment(CMFCatalogAware, WorkflowAware, DynamicType,
Traversable, RoleManager, Owned, Implicit):
"""A comment. """A comment.
This object attempts to be as lightweight as possible. We implement a 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 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) CommentFactory = Factory(Comment)
def notify_workflow(obj, event): def notify_workflow(obj, event):

View File

@ -58,31 +58,31 @@
<subscriber <subscriber
for="plone.app.discussion.interfaces.IComment for="plone.app.discussion.interfaces.IComment
zope.app.container.interfaces.IObjectAddedEvent" zope.lifecycleevent.interfaces.IObjectAddedEvent"
handler=".comment.notify_workflow" handler=".comment.notify_workflow"
/> />
<subscriber <subscriber
for="plone.app.discussion.interfaces.IComment for="plone.app.discussion.interfaces.IComment
zope.app.container.interfaces.IObjectAddedEvent" zope.lifecycleevent.interfaces.IObjectAddedEvent"
handler=".comment.notify_content_object" handler=".comment.notify_content_object"
/> />
<subscriber <subscriber
for="plone.app.discussion.interfaces.IComment for="plone.app.discussion.interfaces.IComment
zope.app.container.interfaces.IObjectRemovedEvent" zope.lifecycleevent.interfaces.IObjectRemovedEvent"
handler=".comment.notify_content_object" handler=".comment.notify_content_object"
/> />
<subscriber <subscriber
for="plone.app.discussion.interfaces.IComment for="plone.app.discussion.interfaces.IComment
zope.app.container.interfaces.IObjectAddedEvent" zope.lifecycleevent.interfaces.IObjectAddedEvent"
handler=".tool.index_object" handler=".tool.index_object"
/> />
<subscriber <subscriber
for="plone.app.discussion.interfaces.IComment for="plone.app.discussion.interfaces.IComment
zope.app.container.interfaces.IObjectRemovedEvent" zope.lifecycleevent.interfaces.IObjectRemovedEvent"
handler=".tool.unindex_object" handler=".tool.unindex_object"
/> />

View File

@ -16,7 +16,7 @@ from persistent import Persistent
from plone.registry.interfaces import IRegistry 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.interface import implements, implementer
from zope.component import adapts, adapter, queryUtility 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 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.lifecycleevent import ObjectAddedEvent
from zope.app.container.contained import ObjectRemovedEvent from zope.lifecycleevent import ObjectRemovedEvent
from BTrees.OIBTree import OIBTree from BTrees.OIBTree import OIBTree

View File

@ -1,12 +1,25 @@
from Testing import ZopeTestCase as ztc
from Products.PloneTestCase import ptc 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): class DiscussionLayer(layer.PloneSite):
"""Install plone.app.discussion""" """Configure plone.app.discussion"""
def afterSetUp(self): @classmethod
self.addProfile('plone.app.discussion:default') 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]) @classmethod
def tearDown(cls):
pass

View File

@ -26,7 +26,6 @@ setup(name='plone.app.discussion',
install_requires=[ install_requires=[
'setuptools', 'setuptools',
'collective.autopermission', 'collective.autopermission',
'collective.testcaselayer',
'plone.app.registry', 'plone.app.registry',
'plone.indexer', 'plone.indexer',
'plone.registry', 'plone.registry',
@ -38,7 +37,9 @@ setup(name='plone.app.discussion',
'zope.component', 'zope.component',
'zope.annotation', 'zope.annotation',
'zope.event', 'zope.event',
'zope.app.container', # XXX: eventually should change to zope.container 'zope.container',
'zope.lifecycleevent',
'zope.site',
], ],
entry_points=""" entry_points="""
[z3c.autoinclude.plugin] [z3c.autoinclude.plugin]