[Zope-CMF] DCWorkflow: trouble with Guard expressions
Shane Hathaway
shane@digicool.com
Mon, 11 Jun 2001 16:20:41 -0400
Jens Quade wrote:
> I think the call to expr() in the check() method in Guard.py
> has to be changed to a call to something equivalent to exprNamespace,
> but without the status change environment. To try this, I
> modified the if expr...: block in check() to look like this:
>
> if expr is not None:
>
> md = TemplateDict()
> md._push(ExprVars(ob, wf_def))
> d = {'object': ob,
> 'workflow': wf_def,
> }
> md._push(d)
> md._push(wf_def.scripts) # Make scripts automatically available.
>
> res = expr(md)
> if not res:
> return 0
>
> I do not really know what I'm doing there... but it works :)
Thanks for the bug report, and your patch is pretty close to correct.
I've moved DCWorkflow to the public CMF repository and you can see how I
fixed it.
> Another suggestion: It would be nice to have a portal object in the
> namespace: I often use e.g. object.portal_membership as workaround,
> but with portal.portal_membership it would be clearer what I'd like to
> do..
getPortal() is now available in expressions. Good idea!
Shane