[Zope-CMF] automatic workflow transitions
Sam Brauer
sam@webslingerz.com
Wed, 16 Jul 2003 12:52:36 -0400
Sam Brauer wrote:
> I have a specific question about scripting automatic workflow
> transitions, and then a more general question.
>
> Regarding scripting automatic transitions:
>
> I have created a new transition (in a DCWorkflow) that I set up to be
> triggered Automatically. I have created a script and set it as the
> "Script (before)" for the transition. I would like for the script to
> allow the transition only if certain criteria are satisfied.
>
> My problem is that I am unsure how the script can "veto" transition.
> Based on some docs I read, I tried raising an exception if the criteria
> weren't met, but I wasn't sure what exception to raise. I tried just
> raising the string "vetoed", but that bubbles up to the user. On a
> hunch, I then tried returning 0 (if I didn't want the transition) or 1
> (if I did), but then the transition always occurred. So evidentally my
> hunch was wrong and the return value is ignored.
>
> Does anyone know the proper way to set up an automatic transition with
> veto power?
I think I figured this out...
Instead of trying to setup a script as the "Script (before)", I tried
modifying the script to return 1 or 0 then called it via the "Guard
Expression" like so:
python:scripts.publishMembersOnly(state_change.object)
This seems to work for me.
I'm still curious about solutions to my other more general question
below...
>
>
> Now for a more general question:
>
> I have a folder in a CMF site the contents of which should only be
> viewable by authenticated users. That means that the content also
> shouldn't show up in search results unless the user is logged in.
> What is the best way to accomplish this goal?
>
> (I tried various approaches already, and so far the best I've been able
> to come up with is a new "members-only" state. After setting up that
> new state, I tried to create a new transition from the published state
> to the members-only state that is triggered if the content is under the
> proper folder. However, I can't figure out how to make the automatic
> transition not occur if the content is in some other folder. Maybe
> someone can offer a better/easier way to accomplish my goal...)
>
>
> Thank you,
> - Sam Brauer
>
>
> _______________________________________________
> Zope-CMF maillist - Zope-CMF@zope.org
> http://mail.zope.org/mailman/listinfo/zope-cmf
>
> See http://collector.zope.org/CMF for bug reports and feature requests
--
Sam Brauer
Systems Programmer
sam@webslingerZ.com