Hi
I am running COREBlog2 0.9b on Plone 2.5.1 and am having a problem getting a
redirect to happen after I change the state of a comment.
I had set up a workflow for blog comments where their initial state is
pending. In order to make it simple for my bloggers I want them to just have
to chose one of 2 options from the state dropdown when they are reviewing
comments either "Publish" or "Reject". I thought the simplest thing for
comments that where rejected would be for their state to be changed to
private so they would then only be visible to the Manager and for the
reviewer they would disappear from view. The Manager could then clean out
any obvious spam from easily by using the comments folder but ones that
where rejected for other reasons could be kept for reference and historical
purposes.
As the default behaviour of a change of state on comment that is up for
review is to display the comment I had the problem where once the comment
state was changed to "Rejected" by the reviewer they would be shown the
login page. I thought the easiest way to get around this would be to have a
script that was called after the reject transition and redirected the user
to the root page of the blog. This is simple to do from a script you add to
a folder:
url = context.portal_url.getPortalPath() + '/blog'
return context.REQUEST['RESPONSE'].redirect(url)
If I test that it works perfectly, however trying to get this to work when
called off a script in a reject transition has been a major exercise in
frustration. Below is an example of an external method that I have written
to attempt this, I moved on to external methods after having no luck getting
something similar to work as a script. I have also tried:
return obj.REQUEST['RESPONSE'].redirect(url)
but that did nothing as well. I get no error messages just no redirect
happens and i see the object in its private state. The redirect does not
happen if I run it as a manager, and I have tried having a news item use the
same workflow with the same result as my coreblog comments. I am obviously
missing some critical piece of understanding about how objects move through
a transition or something along those lines but after days of googling,
reading through the Zopebook scripting chapters searching mailing lists and
looking at the various scripts in the source that mention redirect I have no
idea what it is. Any clues, pointers would be greatly appreciated.
----------------------------------------------
#!/usr/bin/python
##external method to redirect from comment to parent
def redirectTo(self):
obj = self.object
obj.plone_log('Beginning redirectExt')
url = obj.portal_url.getPortalPath() + '/blog'
obj.plone_log(url)
obj.REQUEST['RESPONSE'].redirect(url)
obj.plone_log('after the redirect')
--------------------------------------------------
cheers
John
--
John Habermann
Internet Programmer, System Administrator
The Wilderness Society Inc
http://www.wilderness.org.au
_______________________________________________
COREblog-en mailing list
[email protected]
http://postaria.com/mailman/listinfo/coreblog-en
Unsubscription writing to [EMAIL PROTECTED]