|  | # Cheshire3 Objects: Workflow

## Description

A workflow is similar to the process chain concept of an index, but behaves at a more global level. It will allow the configuration of a workflow using Cheshire3 objects and simple code to be defined and executed for input objects. For example, one might define a common workflow pattern of PreParsers, a Parser and then indexing routines in the XML configuration, and then run each document in a documentFactory through it.

This allows users who are not familiar with Python, but who are familiar with XML and the Cheshire3 design to implement tasks as required by changing only configuration files. It thus also allows a user to configure personal workflows in a Cheshire3 system which they don't have permission to modify.

Workflows have the following capabilities:

- Iterate through a documentGroup, resultSet or Store object
- Check for error conditions
- Call functions on Cheshire3 objects, including other Workflows
- Log text to a Logger object
- Break, Continue, Raise, and Return flow control

## Configuration

Further documentation is available on configuring Cheshire3 workflows:

- Workflow Configuration -- A tutorial on configuring workflows, with illustrative examples.
- Cheshire3 Configuration: Workflows -- Cheshire3 Configuration reference material on the tags used for workflow configuration.

## Implementations

The following implementations are pre-configured and ready to use.
They may be used out-of-the-box in configurations for other Workflows, or in code by getting the object from a Server.
It is also possible to over-ride any or all of these Workflows for a specific application (e.g. by adding additional PreParsers to the PreParserWorkflow) in your database config.

- buildIndexWorkflow
  Workflow to process a loaded DocumentFactory. Before beginning the recordStore and database are prepared for accepting new records. Each Document is passed to buildIndexSingleWorkflow in turn. Afterwards, the recordStore and created indexes are committed to disk.
- buildIndexSingleWorkflow
  Workflow to take a Document, pass each through PreParserWorkflow. The resulting Document is Parsed with a SaxParser. The resulting SaxRecord is stored in the recordStore and then indexed.
- PreParserWorkflow
  Workflow to take a Document, and process it using SgmlPreParser. Returns the resulting Document.

## API

Module: cheshire3.workflow
Classes:

- workflow.SimpleWorkflow
  A basic workflow implementation
- workflow.CachingWorkflow
  Slightly faster workflow implementation that caches the objects it uses. workflow.load_cache(session, newDatabaseObject) must be called if the workflow is to be used in another database.

Methods:

Function | Parameters | Returns | Description
--- | --- | --- | ---
__init__ | domNode, parentObject |  | The constructer takes a DOM tree containing the configuration of the index and the object which the database should consider as its parent, normally a database.
process | session, object | object | Executes the code as constructed from the XML configuration on the given object. The return value is the last object to be produced by the execution.