plone - HTTP redirect after check in event -


i using plone 5.0 plone.app.iterate addon checkout option , intranet/extranet workflow. fuse these 2 concepts idea is: after every workflow transition event handler checks, whether page working copy , if published page. if page automatically should checked in. after review of working copy checked in. in order accomplish wrote following event handler:

from acquisition import aq_inner plone import api plone.app.iterate.interfaces import iworkingcopy, icheckincheckoutpolicy plone.app.iterate import plonemessagefactory _ products.cmfcore.utils import gettoolbyname products.statusmessages.interfaces import istatusmessage  def checkinifneeded(document, event):     context = aq_inner(document)     workflowtool = gettoolbyname(context, "portal_workflow")     status = workflowtool.getstatusof("intranet_workflow", document)     if iworkingcopy.providedby(context) , status["review_state"] == "internally_published":        policy = icheckincheckoutpolicy(context)        baseline = policy.checkin("")        istatusmessage(context.request).addstatusmessage(         _("checked in"), type='info')        view_url = baseline.restrictedtraverse("@@plone_context_state").view_url()        context.request.response.redirect(view_url) 

the code check in pretty source of interface works fine until last line user triggering event should redirected checked in main branch of page. user redirected page of working copy, (which no longer exists), telling user page unavailable. did wrong?

pure redirect call not working everywhere because other redirect can called later (they never works in event handlers).

try add this:

from zexceptions import redirect 

and change last line with:

raise redirect(view_url) 

i'm unsure if must add transaction.commit() transaction module before redirect call.


Comments

Popular posts from this blog

java - Jasper subreport showing only one entry from the JSON data source when embedded in the Title band -

serialization - Convert Any type in scala to Array[Byte] and back -

SonarQube Plugin for Jenkins does not find SonarQube Scanner executable -