[z3-five] Events / Archetypes
Kai Diefenbach
usenet at diefenba.ch
Fri Aug 4 07:34:15 CEST 2006
Hello,
Trying out Zope 3 events I experienced unexpected behaviour. Maybe
someone can help out. I'm using Zope-2.9.4 and Plone 2.5.
Situation: There is a simple content type using Archetypes, which has a
few fields, e.g. text. This content type implements IComment.
There are simple event subscribers:
<snip>
from Products.CMFCore.utils import getToolByName
def notifyAdd(comment, event):
"""
"""
sendMail("Added Comment", entry.text) # text is empty
def changeStatus(comment, event):
"""
"""
wftool = getToolByName(comment, "portal_workflow")
wftool.doActionFor(comment, "publish")
</snip>
And the configure.zcml is:
<snip>
<subscriber
for="Products.EasyBlogG5.interfaces.IComment.IComment
zope.app.container.interfaces.IObjectAddedEvent"
handler=".comment.notifyAdd" />
<subscriber
for="Products.EasyBlogG5.interfaces.IComment.IComment
zope.app.container.interfaces.IObjectAddedEvent"
handler=".comment.changeStatus" />
</snip>
Now the subscribers are called indeed, but all fields of the comment are
empty, that means, within notifyAdd comment.text is "" and
comment.getText() throws a AttributeError.
After processing changeStatus the *history* of the comment object says
it was published but the real state is still visible.
Thanks
Kai
More information about the z3-five
mailing list