Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Zope: CMF

guard expression on workflow transition

 

 

Zope cmf RSS feed   Index | Next | Previous | View Threaded


robichon at esrf

Dec 18, 2007, 7:31 AM

Post #1 of 5 (1018 views)
Permalink
guard expression on workflow transition

Hi,

I have a custom archetype for a seminar announcement. When published
this announcement runs a script to send an email to a mailing list. I
have added to this content type a multiselection widget of checkboxes
(called modified_element) enabling the user to indicate significant
changes to this announcement, and a workflow transition which will send
the email again announcing the changes (date, time etc.)

I would like to add a guard expression to this transition such that it
is available only when the user has actually checked a box in the
multiselection widget.

I have tried:

python:len(here.getModified_element())>0

but the workflow transition is still available in the dropdown.

I have updated the security settings.

Your help would be gratefully appreciated.

Thanks in advance

Marie
Attachments: robichon.vcf (0.27 KB)


l at lrowe

Dec 19, 2007, 1:51 AM

Post #2 of 5 (953 views)
Permalink
Re: guard expression on workflow transition [In reply to]

I use a view like this:

from zope.publisher.browser import BrowserView
from zope.component import getMultiAdapter
from AccessControl.SecurityManagement import getSecurityManager
import transaction

class PDBView(BrowserView):
def __call__(self):
sm = getSecurityManager()
user = sm.getUser()
context = self.context
request = self.request
import pdb; pdb.set_trace()
self.context.portal_workflow.listActions(object=self.context)

registered like this:

<browser:page
for="*"
name="pdb"
class="testing.PDBView"
permission="zope.Public"
/>

together with PDBDebugMode to step through the building of the workflow
menu.

Hope that helps,

Laurence


Marie ROBICHON wrote:
> Hi,
>
> I have a custom archetype for a seminar announcement. When published
> this announcement runs a script to send an email to a mailing list. I
> have added to this content type a multiselection widget of checkboxes
> (called modified_element) enabling the user to indicate significant
> changes to this announcement, and a workflow transition which will send
> the email again announcing the changes (date, time etc.)
>
> I would like to add a guard expression to this transition such that it
> is available only when the user has actually checked a box in the
> multiselection widget.
>
> I have tried:
>
> python:len(here.getModified_element())>0
>
> but the workflow transition is still available in the dropdown.
>
> I have updated the security settings.
>
> Your help would be gratefully appreciated.
>
> Thanks in advance
>
> Marie
>
>
> _______________________________________________
> Zope-CMF maillist - Zope-CMF [at] lists
> http://mail.zope.org/mailman/listinfo/zope-cmf
>
> See http://collector.zope.org/CMF for bug reports and feature requests

_______________________________________________
Zope-CMF maillist - Zope-CMF [at] lists
http://mail.zope.org/mailman/listinfo/zope-cmf

See http://collector.zope.org/CMF for bug reports and feature requests


robichon at esrf

Dec 19, 2007, 3:03 AM

Post #3 of 5 (948 views)
Permalink
Re: guard expression on workflow transition [In reply to]

Sorry, I omitted to point out that I am using Plone 2.1.4.

The solution you kindly pointed out to me is Zope3ish isn't it?? It is
sort of chinese to me....;-) I don't suppose with my version of Plone I
can do this ? If I can where do I put this code ?

I have tried other syntaxes in the guard expression box:

- "python:scripts.checkModifiedElement()" where a python script under
the scripts tags checks the length of getModified_element and returns 0
or 1 accordingly,

- python: python:len(state_change.object.getModified_element())>0

which do not seem to work either.

Thx

Marie



Laurence Rowe wrote:
> I use a view like this:
>
> from zope.publisher.browser import BrowserView
> from zope.component import getMultiAdapter
> from AccessControl.SecurityManagement import getSecurityManager
> import transaction
>
> class PDBView(BrowserView):
> def __call__(self):
> sm = getSecurityManager()
> user = sm.getUser()
> context = self.context
> request = self.request
> import pdb; pdb.set_trace()
> self.context.portal_workflow.listActions(object=self.context)
>
> registered like this:
>
> <browser:page
> for="*"
> name="pdb"
> class="testing.PDBView"
> permission="zope.Public"
> />
>
> together with PDBDebugMode to step through the building of the workflow
> menu.
>
> Hope that helps,
>
> Laurence
>
>
> Marie ROBICHON wrote:
>> Hi,
>>
>> I have a custom archetype for a seminar announcement. When published
>> this announcement runs a script to send an email to a mailing list. I
>> have added to this content type a multiselection widget of checkboxes
>> (called modified_element) enabling the user to indicate significant
>> changes to this announcement, and a workflow transition which will send
>> the email again announcing the changes (date, time etc.)
>>
>> I would like to add a guard expression to this transition such that it
>> is available only when the user has actually checked a box in the
>> multiselection widget.
>>
>> I have tried:
>>
>> python:len(here.getModified_element())>0
>>
>> but the workflow transition is still available in the dropdown.
>>
>> I have updated the security settings.
>>
>> Your help would be gratefully appreciated.
>>
>> Thanks in advance
>>
>> Marie
>>
>>
>> _______________________________________________
>> Zope-CMF maillist - Zope-CMF [at] lists
>> http://mail.zope.org/mailman/listinfo/zope-cmf
>>
>> See http://collector.zope.org/CMF for bug reports and feature requests
>
> _______________________________________________
> Zope-CMF maillist - Zope-CMF [at] lists
> http://mail.zope.org/mailman/listinfo/zope-cmf
>
> See http://collector.zope.org/CMF for bug reports and feature requests
>

_______________________________________________
Zope-CMF maillist - Zope-CMF [at] lists
http://mail.zope.org/mailman/listinfo/zope-cmf

See http://collector.zope.org/CMF for bug reports and feature requests


robichon at esrf

Dec 19, 2007, 3:03 AM

Post #4 of 5 (951 views)
Permalink
Re: guard expression on workflow transition [In reply to]

Sorry, I omitted to point out that I am using Plone 2.1.4.

The solution you kindly pointed out to me is Zope3ish isn't it?? It is
sort of chinese to me....;-) I don't suppose with my version of Plone I
can do this ? If I can where do I put this code ?

I have tried other syntaxes in the guard expression box:

- "python:scripts.checkModifiedElement()" where a python script under
the scripts tags checks the length of getModified_element and returns 0
or 1 accordingly,

- python: python:len(state_change.object.getModified_element())>0

which do not seem to work either.

Thx

Marie



Laurence Rowe wrote:
> I use a view like this:
>
> from zope.publisher.browser import BrowserView
> from zope.component import getMultiAdapter
> from AccessControl.SecurityManagement import getSecurityManager
> import transaction
>
> class PDBView(BrowserView):
> def __call__(self):
> sm = getSecurityManager()
> user = sm.getUser()
> context = self.context
> request = self.request
> import pdb; pdb.set_trace()
> self.context.portal_workflow.listActions(object=self.context)
>
> registered like this:
>
> <browser:page
> for="*"
> name="pdb"
> class="testing.PDBView"
> permission="zope.Public"
> />
>
> together with PDBDebugMode to step through the building of the workflow
> menu.
>
> Hope that helps,
>
> Laurence
>
>
> Marie ROBICHON wrote:
>> Hi,
>>
>> I have a custom archetype for a seminar announcement. When published
>> this announcement runs a script to send an email to a mailing list. I
>> have added to this content type a multiselection widget of checkboxes
>> (called modified_element) enabling the user to indicate significant
>> changes to this announcement, and a workflow transition which will send
>> the email again announcing the changes (date, time etc.)
>>
>> I would like to add a guard expression to this transition such that it
>> is available only when the user has actually checked a box in the
>> multiselection widget.
>>
>> I have tried:
>>
>> python:len(here.getModified_element())>0
>>
>> but the workflow transition is still available in the dropdown.
>>
>> I have updated the security settings.
>>
>> Your help would be gratefully appreciated.
>>
>> Thanks in advance
>>
>> Marie
>>
>>
>> _______________________________________________
>> Zope-CMF maillist - Zope-CMF-lEa0QfImRKZ5o+NzvwT5Tw [at] public
>> http://mail.zope.org/mailman/listinfo/zope-cmf
>>
>> See http://collector.zope.org/CMF for bug reports and feature requests
>
> _______________________________________________
> Zope-CMF maillist - Zope-CMF-lEa0QfImRKZ5o+NzvwT5Tw [at] public
> http://mail.zope.org/mailman/listinfo/zope-cmf
>
> See http://collector.zope.org/CMF for bug reports and feature requests
>



_______________________________________________
Zope-CMF maillist - Zope-CMF [at] lists
http://mail.zope.org/mailman/listinfo/zope-cmf

See http://collector.zope.org/CMF for bug reports and feature requests


l at lrowe

Dec 20, 2007, 1:58 AM

Post #5 of 5 (948 views)
Permalink
Re: guard expression on workflow transition [In reply to]

Put the pdb code in an external method, as shown in this article:
http://www.zopemag.com/Issue009/Section_Articles/article_ZopeAndFlash.html?printit=1

You'll then be able to step into the guard checking.

Laurence


Marie Robichon wrote:
> Sorry, I omitted to point out that I am using Plone 2.1.4.
>
> The solution you kindly pointed out to me is Zope3ish isn't it?? It is
> sort of chinese to me....;-) I don't suppose with my version of Plone I
> can do this ? If I can where do I put this code ?
>
> I have tried other syntaxes in the guard expression box:
>
> - "python:scripts.checkModifiedElement()" where a python script under
> the scripts tags checks the length of getModified_element and returns 0
> or 1 accordingly,
>
> - python: python:len(state_change.object.getModified_element())>0
>
> which do not seem to work either.
>
> Thx
>
> Marie
>
>
>
> Laurence Rowe wrote:
>> I use a view like this:
>>
>> from zope.publisher.browser import BrowserView
>> from zope.component import getMultiAdapter
>> from AccessControl.SecurityManagement import getSecurityManager
>> import transaction
>>
>> class PDBView(BrowserView):
>> def __call__(self):
>> sm = getSecurityManager()
>> user = sm.getUser()
>> context = self.context
>> request = self.request
>> import pdb; pdb.set_trace()
>> self.context.portal_workflow.listActions(object=self.context)
>>
>> registered like this:
>>
>> <browser:page
>> for="*"
>> name="pdb"
>> class="testing.PDBView"
>> permission="zope.Public"
>> />
>>
>> together with PDBDebugMode to step through the building of the
>> workflow menu.
>>
>> Hope that helps,
>>
>> Laurence
>>
>>
>> Marie ROBICHON wrote:
>>> Hi,
>>>
>>> I have a custom archetype for a seminar announcement. When published
>>> this announcement runs a script to send an email to a mailing list. I
>>> have added to this content type a multiselection widget of checkboxes
>>> (called modified_element) enabling the user to indicate significant
>>> changes to this announcement, and a workflow transition which will send
>>> the email again announcing the changes (date, time etc.)
>>>
>>> I would like to add a guard expression to this transition such that it
>>> is available only when the user has actually checked a box in the
>>> multiselection widget.
>>>
>>> I have tried:
>>>
>>> python:len(here.getModified_element())>0
>>>
>>> but the workflow transition is still available in the dropdown.
>>>
>>> I have updated the security settings.
>>>
>>> Your help would be gratefully appreciated.
>>>
>>> Thanks in advance
>>>
>>> Marie
>>>
>>>
>>> _______________________________________________
>>> Zope-CMF maillist - Zope-CMF [at] lists
>>> http://mail.zope.org/mailman/listinfo/zope-cmf
>>>
>>> See http://collector.zope.org/CMF for bug reports and feature requests
>>
>> _______________________________________________
>> Zope-CMF maillist - Zope-CMF [at] lists
>> http://mail.zope.org/mailman/listinfo/zope-cmf
>>
>> See http://collector.zope.org/CMF for bug reports and feature requests
>>
>
> _______________________________________________
> Zope-CMF maillist - Zope-CMF [at] lists
> http://mail.zope.org/mailman/listinfo/zope-cmf
>
> See http://collector.zope.org/CMF for bug reports and feature requests
>

_______________________________________________
Zope-CMF maillist - Zope-CMF [at] lists
http://mail.zope.org/mailman/listinfo/zope-cmf

See http://collector.zope.org/CMF for bug reports and feature requests

Zope cmf RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.