Skip to content

pybonita is a Python wrapper for the Bonita REST API

License

Notifications You must be signed in to change notification settings

julozi/pybonita

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

98 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PyBonita

pybonita is a Python wrapper for the Bonita REST API

Python packages installation

python setup.py install

Documentation

You can build the documentation with make doc On Github, you can find the documentation from gh-pages

Examples

Here are 2 examples using the PyBonita library

Creating a new case

# -*- coding: utf-8 -*-
from pybonita import BonitaServer
from pybonita import BonitaCase, BonitaProcess

def main():
    # Connect with the Bonita server
    BonitaServer.use('localhost', 9090, 'restuser', 'restbpm')

    # Retrieve the process where we want a new case open
    process = BonitaProcess.get(u'MyProcess--1.0')

    # Initialize params of the Case : use your own names here
    variables = {'demandeur':'julien',
                 'titre':'Au secours',
                 'demande_initiale':'Plein de soucis'}

    # Prepare the new case
    case = BonitaCase(process=process, variables=variables)

    # Add an attachment
    filepath = "~/Desktop/machin.txt"
    case.add_attachment(name="pj", filepath=filepath)

    # Create the new case on the bonita server
    case.start()

if __name__ == '__main__':
    main()

Creating a new user in a group, for a given role

#-*- coding: utf-8 -*-
from pybonita import BonitaServer
from pybonita import BonitaUser, BonitaGroup, BonitaRole, BonitaMembership


def main():
    # Setup the connexion to the server
    BonitaServer.use('localhost', 9090, 'restuser', 'restbpm', ['latin-1'])

    # Retrieve group of "response entreprise"
    group = BonitaGroup.get(path='/platform/responsables_entreprise')

    # Retrieve users allready registrered in this group
    allready_registered_users = BonitaUser.find(group=group)

    # Get role "user"
    role = BonitaRole.get(name='user')

    # Get Membership for group and role
    membership = BonitaMembership.get(group=group, role=role)

    # Register new user for this group and role
    user = BonitaUser(username='email@user.com', password='123456')
    user.memberships.append(membership)
    user.save()


if __name__ == '__main__':
    main()

About

pybonita is a Python wrapper for the Bonita REST API

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published