[Product-Developers] redirect ordinary member after creating content
Kees Hink
hink at gw20e.com
Wed May 11 12:09:17 UTC 2011
Regular users can add content, but they shouldn't see the Plone interface if
possible. Therefore, when they create an item, i'd like them to see a page that
only displays a simple message (like "thanks for your story. we'll have a look
at it").
Currently, i'm trying to do this using an event handler, redirecting to a
specific view on the created object:
<!-- configure.zcml: -->
<subscriber
for="hvvg.content.interfaces.IVerhaal
zope.lifecycleevent.interfaces.IObjectModifiedEvent"
handler="hvvg.content.events.redirect" />
## events.py
def redirect(context, event):
"""After creation, redirect to "thank-you" kind of page if member has no
additional roles."""
mtool = getToolByName(context, "portal_membership")
roles = mtool.getAuthenticatedMember().getRoles()
roles_not_to_have = ['Manager','Editor', 'Contributor', 'Reader',
'Reviewer']
if set(roles).isdisjoint(roles_not_to_have):
context.REQUEST.RESPONSE.redirect(event.object.absolute_url() +
'/verhaal-ingestuurd')
This does not seem to work: the response redirect is executed, but the user
sees the object instead of the view. Any idea why, and/or how to do it better?
This is on Plone 4.1.
Kees
More information about the Product-Developers
mailing list