263 | | # Determine which object is being displayed (i.e. realm), |
264 | | # based on Wiki page name and the presence of the planid |
265 | | # request parameter. |
266 | | realm = None |
267 | | if page_name.find('_TC') >= 0: |
268 | | if not planid or planid == '-1': |
269 | | realm = 'testcase' |
270 | | key = {'id': page_name.rpartition('_TC')[2]} |
271 | | else: |
272 | | realm = 'testcaseinplan' |
273 | | key = {'id': page_name.rpartition('_TC')[2], 'planid': planid} |
274 | | else: |
275 | | if not planid or planid == '-1': |
276 | | realm = 'testcatalog' |
277 | | key = {'id': page_name.rpartition('_TT')[2]} |
278 | | else: |
279 | | realm = 'testplan' |
280 | | key = {'id': planid} |
281 | | |
282 | | id = get_string_from_dictionary(key) |
283 | | res = Resource(realm, id) |
284 | | |
285 | | workflow_markup = ResourceWorkflowSystem(self.env).get_workflow_markup(req, '..', realm, res) |
| 256 | realm = 'testcase' |
| 257 | key = {'id': page_name.rpartition('_TC')[2]} |
| 258 | |
| 259 | id = get_string_from_dictionary(key) |
| 260 | res = Resource(realm, id) |
| 261 | |
| 262 | # This is where we ask the workflow engine to generate the HTML markup |
| 263 | # to be displayed in the web page to let the User change a resource workflow state |
| 264 | workflow_markup = ResourceWorkflowSystem(self.env).get_workflow_markup(req, '..', realm, res) |
| 289 | |
| 290 | == Programmatic Interface == |
| 291 | |
| 292 | The workflow engine comes with a programmatic interface, letting other plugins interact with the workflow lifecycle. |
| 293 | |
| 294 | There are two interfaces that let you interact with the workflow transitions: |
| 295 | |
| 296 | 1. You can give or deny permission to actually perform the transition => IWorkflowTransitionAuthorization |
| 297 | 2. Being notified of state transitions => IWorkflowTransitionListener |
| 298 | |
| 299 | |
| 300 | === IWorkflowTransitionAuthorization === |
| 301 | |
| 302 | {{{ |
| 303 | class IWorkflowTransitionAuthorization(Interface): |
| 304 | """ |
| 305 | Extension point interface for components that wish to augment the |
| 306 | state machine at runtime, by allowing or denying each transition |
| 307 | based on the object and the current and new states. |
| 308 | """ |
| 309 | |
| 310 | def is_authorized(res_wf_state, resource, action, old_state, new_state): |
| 311 | """ |
| 312 | Called before allowing the transition. |
| 313 | Return True to allow for the transition, False to deny it. |
| 314 | |
| 315 | :param res_wf_state: the ResourceWorkflowState being |
| 316 | transitioned from old_state to new_state |
| 317 | :param resource: the Resource object being transitioned. |
| 318 | :param action: the action being performed. |
| 319 | """ |
| 320 | }}} |
| 321 | |
| 322 | === IWorkflowTransitionListener === |
| 323 | |
| 324 | {{{ |
| 325 | class IWorkflowTransitionListener(Interface): |
| 326 | """ |
| 327 | Extension point interface for components that require notification |
| 328 | when objects transition between states. |
| 329 | """ |
| 330 | |
| 331 | def object_transition(res_wf_state, resource, action, old_state, new_state): |
| 332 | """ |
| 333 | Called when an object has transitioned to a new state. |
| 334 | |
| 335 | :param res_wf_state: the ResourceWorkflowState |
| 336 | transitioned from old_state to new_state |
| 337 | :param resource: the Resource object transitioned. |
| 338 | :param action: the action been performed. |
| 339 | """ |
| 340 | }}} |
| 341 | |