Workflow

Defines navigation for your application, which views trigger other views and which actions are called that trigger views.

You would need:

  1. Actions: Flow navigation is triggered by action components. You need to define actions that will navigate to other views.

  2. Flow Variables: In order to define conditions for your flow, you would need to define variables. You register flow variables

    with register methods and define flows with variable values.

  3. Label methods: Include decorator into your views and actions to let ximpia know they must follow flows.

Ximpia would query which view to show when actions are executed. You don’t need to code navigation for your application. When your flow changes, you update variables and flow parameters and your flow is changes (For example, to plug in a new view).

We define flow and simple navigation without conditions. You would register flow in components.py:

self._reg.registerFlow(__name__, flowCode='login')
self._reg.registerFlowView(__name__, flowCode='login', viewNameSource=Views.LOGIN,
    viewNameTarget=Views.HOME_LOGIN, actionName='login', order=10)

And then write flow variables in your service layer in action methods:

self._put_flow_params(my_var='Customer')

Workflow would have enough info on which views to navigate to.

Decorators

  • ximpia.xpcore.service.workflow_view (flow_code, form) : Label view and relate to flow. Set main form to be used.
  • ximpia.xpcore.service.workflow_action (flow_code, form) : Label action and relate to flow. Set main form to be used for validation.

Models

class ximpia.xpcore.models.Workflow(*args, **kwargs)[source]

WorkFlow.

Ximpia comes with a basic application workflow to provide navigation for your views.

Navigation is provided in window and popup window types.

You “mark” as workflow view any service method with flow code (decorator). Actions are also “marked” as worflow actions with decorators.

When actions are triggered by clicking on a button or similar, action logic is executed, and user displays view based on flow information and data inserted in the flow by actions. You do not have to map navigation inside your service operations.

Plugging in a new view is pretty simple. You code the service view operation, include it in your flow, and view (window or popup) will be displayed when requirements are met

Attributes

  • id:AutoField : Primary Key
  • code:CharField(15) : Flow code
  • resetStart:BooleanField : The flow data will be deleted when user displays first view of flow. The flow will be reset when

user visits again any page in the flow. * deleteOnEnd:BooleanField : Flow data is deleted when user gets to final view in the flow. * jumpToView:BooleanField : When user visits first view in the flow, will get redirected to last visited view in the flow. User jumps to last view in the flow.

Relationships

  • application -> Application
class ximpia.xpcore.models.WorkflowView(*args, **kwargs)[source]

WorkFlow View. Relationship between flows and your views.

Source view triggers action, logic is executed and target view is displayed to user.

Attributes

  • id:AutoField : Primary Key
  • order:IntegerField : View orderi flow. You can place order like 10, 20, 30 for views in our flow. And then later inyect views

between those values, like 15, for example.

Relationships

  • flow -> WorkFlow
  • viewSource -> View : Source view for flow
  • viewTarget -> View : Target view for flow
  • action -> Action : Action mapped to flow. Source view triggers action, logic is executed and target view is rendered and

displayed. * params <-> Param through WFParamValue with related name ‘flowView_params’

class ximpia.xpcore.models.WorkflowData(*args, **kwargs)[source]

User Workflow Data

userId is the workflow user id. Flows support authenticated users and anonymous users. When flows start, in case not authenticated, workflow user id is generated. This feature allows having a flow starting at non-authenticated views and ending in authenticated views, as well as non-auth flows.

Attributes

  • id:AutoField : Primary Key
  • userId:CharField(40) : Workflow user id
  • data:TextField : Workflow data encoded in json and base64

Relationships

  • flow -> Workflow
  • view -> View

Service

Service methods that deal with workflow are:

class ximpia.xpcore.service.CommonService(ctx)[source]
_put_flow_params(**args)[source]

Put parameters into workflow or navigation system. @param args: Arguments to insert into persistence

_get_target_view()[source]

Get target view.

_get_flow_params(*name_list)[source]

Get parameter for list given, either from workflow dictionary or parameter dictionary in view. @param name_list: List of parameters to fetch

_get_wf_user()[source]

Get Workflow user.

WorkflowBusiness

class ximpia.xpcore.business.WorkFlowBusiness(ctx)[source]
build_flow_data_dict(flow_data)[source]

Build the flow data dictionary having the flowData instance. @param flowData: Flow data @return: flow_data_dict

gen_user_id()[source]

Generate workflow user id.

** Returns ** user_id

get(flow_code)[source]

Get flow.

get_flow_data_dict(wf_user_id, flow_code)[source]

Get flow data dictionary for user and flow code @param wf_user_id: Workflow user id @param flow_code: flowCode @return: flow_data_dict : Dictionary

get_flow_view_by_action(action_name)[source]

Get flow by action name. It queries the workflow data and returns flow associated with actionName @param action_name: Action name @return: flow_view: Workflow view

get_param(name)[source]

Get workflow parameter from context @param name: Name @return: Param Value

get_param_from_ctx(name)[source]

Get flow parameter from context. @param name: Parameter name @return: Parameter value

get_view(wf_user_id, flow_code)[source]

Get view from flow @param wf_user_id: User @param flow_code: Flow code @return: view_name

get_view_name()[source]

Get workflow view name. @return: viewName

get_view_params(flow_code, view_name)[source]

Get view entry parameters for view and flow @param flow_code: Flow code @param view_name: View name @return: param_dict

is_first_view(flow_code, view_name)[source]

Checks if view is first in flow. It uses field ‘order’ to determine if is first view.

is_last_view(view_name_source, view_name_target, action_name)[source]

Checks if view is last in flow.

put_params(**argsDict)[source]

Put list of workflow parameters in context @param argsDict: Argument dictionary

remove_data(wf_user_id, flow_code)[source]

Removes the workflow data for user or session.

reset_flow(wf_user_id, flow_code, view_name)[source]

Reset flow. It deletes all workflow variables and view name @param wf_user_id: Workflow User Id @param flow_code: Flow code

resolve_flow_data_for_user(wf_user_id, flow_code)[source]

Resolves flow for user and session key. @param wf_user_id: Workflow User Id @param flow_code: Flow code @return: resolved_flow : Resolved flow for flow code , login user or session

resolve_view(wf_user_id, app_name, flow_code, view_name_source, action_name)[source]

Search destiny views with origin viewSource and operation actionName @param view_name_source: Origin view @param action_name: Action name @return: view_target

save(wf_user_id, flow_code)[source]

Saves the workflow into database for user @param user: User @param flowCode: Flow code

set_view_name(view_name)[source]

Set view name in Workflow @param view_name: View name

Table Of Contents

Previous topic

Core Models

Next topic

Service Layer

This Page