Introduction
Visure Server 8 allows the creation of Python scripts that are loaded in the server and execute tasks whenever a given event is triggered. For instance, sending an email, changing an attribute value, or preventing the editing of a description.
Installation
In order to create a Python script, a valid .py file needs to be loaded at Python Scripts tab in the Visure Server :
There can be as many .py files as needed.
Events
The following Python file includes all the possible events that can trigger a script:
Each event exists in two modes, before and after event. If the result of an event is False, the event will NOT be triggered.
For instance, if a script associated to def Visure_beforeChangeDescription(bl, lID, lCRC32), calculates that the user is not able to change the description based on the fact that an attribute "Status" is set to "Approved", the user can return a False value, and the event, editing the description in this case, will not be completed.
Actions
The scripts use Visure´s datalayer to access information from the database. The access rights to the information will be based on the user that triggers the event. For instance, if the user doesn´t have access right to modify an attribute, the script won´t either.
The scripts may include actions like reading and editing system and user attributes, traceability, creating other items and so on.
Samples
Here are some sample Python scripts that need to be tailored to your own database and projects:
Sample #1: The following script prevents a user from editing a description if the Status attribute is set to Approved
Sample #2: The following script reverts the Status attribute back to New when a user edits the description of an item
Sample #3: The following script sends an email to the author of a requirement when a comment or a reply is created
Sample #4: The following script allows defining the access rights over a document or individual items based on a list of approvers, reviewers, and a due date.
Sample #5: The following script automatically calculates the status of a test case based on the status of the steps.
Miscellaneous
- Python Scripts are read and cached by the Python environment when the Visure Server process starts, so you have to restart the Visure Server to take script changes into account.
- Scripts are executed on the server side, so log traces are dumped on server log file.
- You have to include all the scripting logic in one single module.
- afterXXX events don't stop server operations. Due to Visure's new server/client architecture, to properly update server shared data, only beforeXXX event handlers can stop Visure operations returning a false value. On afterXXX event handlers, return value is ignored.
- Item check in events are only fired if the elements have changes. Due to the smart check in feature, when items have no changes, an undo check out operation is performed, so check in events are not fired.
Python Reference Guide
The following guide provides a reference to programmers on the actions available in the scripts
Download Python Reference Guide
Comments
0 comments
Please sign in to leave a comment.