1 | # |
---|
2 | # Generated by dumpDCWorkflow.py written by Sebastien Bigaret |
---|
3 | # Original workflow id/title: simpleblog_workflow/SimpleBlog Workflow |
---|
4 | # Date: 2003/11/06 09:34:25.960 GMT+1 |
---|
5 | # |
---|
6 | # WARNING: this dumps does NOT contain any scripts you might have added to |
---|
7 | # the workflow, IT IS YOUR RESPONSABILITY TO MAKE BACKUPS FOR THESE SCRIPTS. |
---|
8 | # |
---|
9 | # No script detected in this workflow |
---|
10 | # |
---|
11 | """ |
---|
12 | Programmatically creates a workflow type |
---|
13 | """ |
---|
14 | script_sbPublishEntry = """## Script (Python) "sbPublishEntry" |
---|
15 | ##bind container=container |
---|
16 | ##bind context=context |
---|
17 | ##bind namespace= |
---|
18 | ##bind script=script |
---|
19 | ##bind subpath=traverse_subpath |
---|
20 | ##parameters=change_state=None |
---|
21 | ##title=Change an entrys' state to publish |
---|
22 | ## |
---|
23 | obj = change_state.object |
---|
24 | if obj.restrictedTraverse('portal_pingtool',None): |
---|
25 | obj.portal_pingtool.pingFeedReader(obj) |
---|
26 | tbping=obj.sendTrackBack() |
---|
27 | return tbping |
---|
28 | """ |
---|
29 | |
---|
30 | __version__ = "$Revision: 1.3 $"[11:-2] |
---|
31 | |
---|
32 | from Products.CMFCore.WorkflowTool import addWorkflowFactory |
---|
33 | |
---|
34 | from Products.DCWorkflow.DCWorkflow import DCWorkflowDefinition |
---|
35 | |
---|
36 | def createSimpleblog_workflow(id): |
---|
37 | "..." |
---|
38 | ob = DCWorkflowDefinition(id) |
---|
39 | setupSimpleblog_workflow(ob) |
---|
40 | return ob |
---|
41 | |
---|
42 | def setupSimpleblog_workflow(wf): |
---|
43 | "..." |
---|
44 | wf.setProperties(title='SimpleBlog Workflow') |
---|
45 | |
---|
46 | for s in ['published', 'draft']: |
---|
47 | wf.states.addState(s) |
---|
48 | for t in ['publish', 'retract']: |
---|
49 | wf.transitions.addTransition(t) |
---|
50 | for v in ['review_history', 'comments', 'time', 'actor', 'action']: |
---|
51 | wf.variables.addVariable(v) |
---|
52 | for l in []: |
---|
53 | wf.worklists.addWorklist(l) |
---|
54 | for p in ('Access contents information', 'Modify portal content', 'View'): |
---|
55 | wf.addManagedPermission(p) |
---|
56 | |
---|
57 | from Products.PythonScripts.PythonScript import manage_addPythonScript |
---|
58 | for p in ['sbPublishEntry']: |
---|
59 | manage_addPythonScript(wf.scripts, p) |
---|
60 | srcdef = wf.scripts['sbPublishEntry'] |
---|
61 | srcdef.ZPythonScript_edit('', script_sbPublishEntry) |
---|
62 | |
---|
63 | ## Initial State |
---|
64 | wf.states.setInitialState('draft') |
---|
65 | |
---|
66 | ## States initialization |
---|
67 | sdef = wf.states['published'] |
---|
68 | sdef.setProperties(title="""Public""", |
---|
69 | transitions=('retract',)) |
---|
70 | sdef.setPermission('Access contents information', 1, ['Anonymous', 'Manager']) |
---|
71 | sdef.setPermission('Modify portal content', 0, ['Manager', 'Owner']) |
---|
72 | sdef.setPermission('View', 0, ['Anonymous', 'Authenticated', 'Manager']) |
---|
73 | |
---|
74 | sdef = wf.states['draft'] |
---|
75 | sdef.setProperties(title="""""", |
---|
76 | transitions=('publish',)) |
---|
77 | sdef.setPermission('Access contents information', 0, ['Manager', 'Owner']) |
---|
78 | sdef.setPermission('Modify portal content', 0, ['Manager', 'Owner']) |
---|
79 | sdef.setPermission('View', 0, ['Manager', 'Owner']) |
---|
80 | |
---|
81 | |
---|
82 | ## Transitions initialization |
---|
83 | tdef = wf.transitions['publish'] |
---|
84 | tdef.setProperties(title="""Reviewer publishes content""", |
---|
85 | new_state_id="""published""", |
---|
86 | trigger_type=1, |
---|
87 | script_name="""""", |
---|
88 | after_script_name='sbPublishEntry', |
---|
89 | actbox_name="""Publish""", |
---|
90 | actbox_url="""%(content_url)s/content_publish_form""", |
---|
91 | actbox_category="""workflow""", |
---|
92 | props={'guard_roles': 'Manager; Owner'}, |
---|
93 | ) |
---|
94 | |
---|
95 | tdef = wf.transitions['retract'] |
---|
96 | tdef.setProperties(title="""Member retracts published item""", |
---|
97 | new_state_id="""draft""", |
---|
98 | trigger_type=1, |
---|
99 | script_name="""""", |
---|
100 | after_script_name="""""", |
---|
101 | actbox_name="""Retract""", |
---|
102 | actbox_url="""%(content_url)s/content_retract_form""", |
---|
103 | actbox_category="""workflow""", |
---|
104 | props={'guard_roles': 'Owner; Manager'}, |
---|
105 | ) |
---|
106 | |
---|
107 | ## State Variable |
---|
108 | wf.variables.setStateVar('review_state') |
---|
109 | |
---|
110 | ## Variables initialization |
---|
111 | vdef = wf.variables['review_history'] |
---|
112 | vdef.setProperties(description="""Provides access to workflow history""", |
---|
113 | default_value="""""", |
---|
114 | default_expr="""state_change/getHistory""", |
---|
115 | for_catalog=0, |
---|
116 | for_status=0, |
---|
117 | update_always=0, |
---|
118 | props={'guard_permissions': 'Request review; Review portal content'}) |
---|
119 | |
---|
120 | vdef = wf.variables['comments'] |
---|
121 | vdef.setProperties(description="""Comments about the last transition""", |
---|
122 | default_value="""""", |
---|
123 | default_expr="""python:state_change.kwargs.get('comment', '')""", |
---|
124 | for_catalog=0, |
---|
125 | for_status=1, |
---|
126 | update_always=1, |
---|
127 | props=None) |
---|
128 | |
---|
129 | vdef = wf.variables['time'] |
---|
130 | vdef.setProperties(description="""Time of the last transition""", |
---|
131 | default_value="""""", |
---|
132 | default_expr="""state_change/getDateTime""", |
---|
133 | for_catalog=0, |
---|
134 | for_status=1, |
---|
135 | update_always=1, |
---|
136 | props=None) |
---|
137 | |
---|
138 | vdef = wf.variables['actor'] |
---|
139 | vdef.setProperties(description="""The ID of the user who performed the last transition""", |
---|
140 | default_value="""""", |
---|
141 | default_expr="""user/getId""", |
---|
142 | for_catalog=0, |
---|
143 | for_status=1, |
---|
144 | update_always=1, |
---|
145 | props=None) |
---|
146 | |
---|
147 | vdef = wf.variables['action'] |
---|
148 | vdef.setProperties(description="""The last transition""", |
---|
149 | default_value="""""", |
---|
150 | default_expr="""transition/getId|nothing""", |
---|
151 | for_catalog=0, |
---|
152 | for_status=1, |
---|
153 | update_always=1, |
---|
154 | props=None) |
---|
155 | |
---|
156 | ## Worklists Initialization |
---|
157 | |
---|
158 | |
---|
159 | |
---|
160 | def wfTest(): |
---|
161 | return 'ok' |
---|
162 | |
---|
163 | addWorkflowFactory(createSimpleblog_workflow, |
---|
164 | id='simpleblog_workflow', |
---|
165 | title='Workflow for Blog Entries') |
---|
166 | |
---|
167 | |
---|