How do you assign a workflow to objects via a script/code?

classic Classic list List threaded Threaded
6 messages Options
Edward Muller Edward Muller
Reply | Threaded
Open this post in threaded view
|

How do you assign a workflow to objects via a script/code?

I need to assign a workflow via a script to objects. We migrated a site and the workflow names of a product changed. So we need to assign the new workflow to all of the objects.

Any idea how to do this?

--
Good Luck & God Speed,

Edward Muller
Owner - Interlix, LLC
417.862.0573
http://interlix.com


-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Plone-Users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/plone-users
Edward Muller Edward Muller
Reply | Threaded
Open this post in threaded view
|

Re: How do you assign a workflow to objects via a script/code?

And no, we can't update the workflow via the workflow tool. It's more complex than that.

----- Original Message -----
From: Edward A. Muller <[hidden email]>
To: [hidden email]
Sent: Friday, December 1, 2006 7:01:19 PM GMT-0600 US/Central
Subject: [Plone-Users] How do you assign a workflow to objects via a script/code?

I need to assign a workflow via a script to objects. We migrated a site and the workflow names of a product changed. So we need to assign the new workflow to all of the objects.

Any idea how to do this?

--
Good Luck & God Speed,

Edward Muller
Owner - Interlix, LLC
417.862.0573
http://interlix.com


-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Plone-Users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/plone-users


--
Good Luck & God Speed,

Edward Muller
Owner - Interlix, LLC
417.862.0573
http://interlix.com


-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Plone-Users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/plone-users
redcor redcor
Reply | Threaded
Open this post in threaded view
|

Re: How do you assign a workflow to objects via a script/code?

Edward A. Muller wrote:

> And no, we can't update the workflow via the workflow tool. It's more complex than that.
>
> ----- Original Message -----
> From: Edward A. Muller <[hidden email]>
> To: [hidden email]
> Sent: Friday, December 1, 2006 7:01:19 PM GMT-0600 US/Central
> Subject: [Plone-Users] How do you assign a workflow to objects via a script/code?
>
> I need to assign a workflow via a script to objects. We migrated a site and the workflow names of a product changed. So we need to assign the new workflow to all of the objects.
>
> Any idea how to do this?
>
this can easily be done by a script.
your new workflow needs a transition that allows to change
from the old state to the new one.
then you create a script that works along the following lines:

wt = context.portal_workflow
for brain in context.portal_catalog( review_state ='MYOLDSTATE'):
  o = brain.getObject()
  wt.doActionFor( o, 'TRANSITIONTOREACHNEWSTATE' comment='set by script' )

hth
robert

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Plone-Users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/plone-users

robert.vcf (211 bytes) Download Attachment
Edward Muller Edward Muller
Reply | Threaded
Open this post in threaded view
|

Re: How do you assign a workflow to objects via a script/code?

I don't want to change state. I know how to do that. I want to change the workflow assigned to that object.

----- Original Message -----
From: robert rottermann <[hidden email]>
To: Edward A. Muller <[hidden email]>
Cc: [hidden email]
Sent: Sunday, December 3, 2006 11:23:03 PM GMT-0600 US/Central
Subject: Re: [Plone-Users] How do you assign a workflow to objects via a script/code?

Edward A. Muller wrote:

> And no, we can't update the workflow via the workflow tool. It's more complex than that.
>
> ----- Original Message -----
> From: Edward A. Muller <[hidden email]>
> To: [hidden email]
> Sent: Friday, December 1, 2006 7:01:19 PM GMT-0600 US/Central
> Subject: [Plone-Users] How do you assign a workflow to objects via a script/code?
>
> I need to assign a workflow via a script to objects. We migrated a site and the workflow names of a product changed. So we need to assign the new workflow to all of the objects.
>
> Any idea how to do this?
>
this can easily be done by a script.
your new workflow needs a transition that allows to change
from the old state to the new one.
then you create a script that works along the following lines:

wt = context.portal_workflow
for brain in context.portal_catalog( review_state ='MYOLDSTATE'):
  o = brain.getObject()
  wt.doActionFor( o, 'TRANSITIONTOREACHNEWSTATE' comment='set by script' )

hth
robert


--
Good Luck & God Speed,

Edward Muller
Owner - Interlix, LLC
417.862.0573
http://interlix.com


-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Plone-Users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/plone-users
Edward Muller Edward Muller
Reply | Threaded
Open this post in threaded view
|

Re: How do you assign a workflow to objects via a script/code?

And no,  portal_workflow.setChainForPortalTypes([..], workflow_id) doesn't work. That sets it for the type. I need to set the workflow for a set of objects, that's it. Once the workflow for those objects is set correctly they will work properly. New objects are already created with the correct workflow.

----- Original Message -----
From: Edward A. Muller <[hidden email]>
To: robert rottermann <[hidden email]>
Cc: [hidden email]
Sent: Monday, December 4, 2006 11:02:14 AM GMT-0600 US/Central
Subject: Re: [Plone-Users] How do you assign a workflow to objects via a script/code?

I don't want to change state. I know how to do that. I want to change the workflow assigned to that object.

----- Original Message -----
From: robert rottermann <[hidden email]>
To: Edward A. Muller <[hidden email]>
Cc: [hidden email]
Sent: Sunday, December 3, 2006 11:23:03 PM GMT-0600 US/Central
Subject: Re: [Plone-Users] How do you assign a workflow to objects via a script/code?

Edward A. Muller wrote:

> And no, we can't update the workflow via the workflow tool. It's more complex than that.
>
> ----- Original Message -----
> From: Edward A. Muller <[hidden email]>
> To: [hidden email]
> Sent: Friday, December 1, 2006 7:01:19 PM GMT-0600 US/Central
> Subject: [Plone-Users] How do you assign a workflow to objects via a script/code?
>
> I need to assign a workflow via a script to objects. We migrated a site and the workflow names of a product changed. So we need to assign the new workflow to all of the objects.
>
> Any idea how to do this?
>
this can easily be done by a script.
your new workflow needs a transition that allows to change
from the old state to the new one.
then you create a script that works along the following lines:

wt = context.portal_workflow
for brain in context.portal_catalog( review_state ='MYOLDSTATE'):
  o = brain.getObject()
  wt.doActionFor( o, 'TRANSITIONTOREACHNEWSTATE' comment='set by script' )

hth
robert


--
Good Luck & God Speed,

Edward Muller
Owner - Interlix, LLC
417.862.0573
http://interlix.com


-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Plone-Users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/plone-users


--
Good Luck & God Speed,

Edward Muller
Owner - Interlix, LLC
417.862.0573
http://interlix.com


-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Plone-Users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/plone-users
Edward Muller Edward Muller
Reply | Threaded
Open this post in threaded view
|

Re: How do you assign a workflow to objects via a script/code?

Never mind. The workflow was assigned properly. But a transition was missing. Man I must have been out of it.

----- Original Message -----
From: Edward A. Muller <[hidden email]>
Cc: [hidden email], robert rottermann <[hidden email]>
Sent: Monday, December 4, 2006 4:06:14 PM GMT-0600 US/Central
Subject: Re: [Plone-Users] How do you assign a workflow to objects via a script/code?

And no,  portal_workflow.setChainForPortalTypes([..], workflow_id) doesn't work. That sets it for the type. I need to set the workflow for a set of objects, that's it. Once the workflow for those objects is set correctly they will work properly. New objects are already created with the correct workflow.

----- Original Message -----
From: Edward A. Muller <[hidden email]>
To: robert rottermann <[hidden email]>
Cc: [hidden email]
Sent: Monday, December 4, 2006 11:02:14 AM GMT-0600 US/Central
Subject: Re: [Plone-Users] How do you assign a workflow to objects via a script/code?

I don't want to change state. I know how to do that. I want to change the workflow assigned to that object.

----- Original Message -----
From: robert rottermann <[hidden email]>
To: Edward A. Muller <[hidden email]>
Cc: [hidden email]
Sent: Sunday, December 3, 2006 11:23:03 PM GMT-0600 US/Central
Subject: Re: [Plone-Users] How do you assign a workflow to objects via a script/code?

Edward A. Muller wrote:

> And no, we can't update the workflow via the workflow tool. It's more complex than that.
>
> ----- Original Message -----
> From: Edward A. Muller <[hidden email]>
> To: [hidden email]
> Sent: Friday, December 1, 2006 7:01:19 PM GMT-0600 US/Central
> Subject: [Plone-Users] How do you assign a workflow to objects via a script/code?
>
> I need to assign a workflow via a script to objects. We migrated a site and the workflow names of a product changed. So we need to assign the new workflow to all of the objects.
>
> Any idea how to do this?
>
this can easily be done by a script.
your new workflow needs a transition that allows to change
from the old state to the new one.
then you create a script that works along the following lines:

wt = context.portal_workflow
for brain in context.portal_catalog( review_state ='MYOLDSTATE'):
  o = brain.getObject()
  wt.doActionFor( o, 'TRANSITIONTOREACHNEWSTATE' comment='set by script' )

hth
robert


--
Good Luck & God Speed,

Edward Muller
Owner - Interlix, LLC
417.862.0573
http://interlix.com


-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Plone-Users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/plone-users


--
Good Luck & God Speed,

Edward Muller
Owner - Interlix, LLC
417.862.0573
http://interlix.com


-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Plone-Users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/plone-users


--
Good Luck & God Speed,

Edward Muller
Owner - Interlix, LLC
417.862.0573
http://interlix.com


-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Plone-Users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/plone-users