[Zope-CMF] Updating workflow variables from within scripts

Florent Guillaume fg@nuxeo.com
20 Mar 2003 20:11:54 +0100


On Thu, 2003-03-20 at 20:03, Adam Fields wrote:
> On Thu, Mar 20, 2003 at 07:49:41PM +0100, Florent Guillaume wrote:
> > In article <20030319001628.GB6874@eye.surgam.net> you write:
> > > Using DCWorkflow...
> > > 
> > > I can update custom workflow variables from a transition expression,
> > > but I haven't been able to get it working from a script that's
> > > executed as part of a transition.
> > 
> > "to get it working" = ?
> > If you mean update a variable "from" a script, no, it doesn't work like
> > that. The variables can be changed only by specific expressions in
> > transitions or in their definition itself.
> 
> Specifically, what I want to do is this:
> 
> 1) Keep track of how many times a particular object has gone through a
>    complete workflow. Examples are very lacking - does the expression
>    syntax support mathematical operations? I couldn't figure out how
>    to increment a workflow variable in a transition expression.

Yes I'd increment a variable in the transition looping back to the
initial state. To increment a var you'd use something like (see more doc
in doc/expressions.stx):
   python:status.myvar + 1

(DCWorkflow.Expression.createExprContext has the full expression context
definition if the doc is not enough.)

> 2) When a child object completes its workflow, I'd like to have it set
>    a flag in its parent object telling it that the content contained
>    within is ready. So, for example, if I have an article and an
>    image within it, I'd like for the article to know whether the image
>    is "done" or not.

The child could provoke a given transition on the parent that changes a
variable.

> If properties are actually a better way, I'll buy that, but it seems
> to me that this is exactly the kind of thing workflow variables should
> be usable for, through scripts.

No workflow variables are fine for your examples.

Florent

-- 
Florent Guillaume, Nuxeo (Paris, France)
+33 1 40 33 79 87  http://nuxeo.com  mailto:fg@nuxeo.com