Python Implementation in Guardian
Overview
The Guardian platform now supports Python scripting within its Custom Logic blocks, expanding its flexibility and enabling developers to perform complex computations and logic more easily. This feature introduces a new Script Language selection option and includes enhancements to VC (Verifiable Credential) document schemas for better version tracking.
1. Custom Logic Block: Script Language Selection
A new dropdown setting has been added to the Custom Logic block in the Policy Editor, allowing users to select the desired scripting language.
π§ Configuration
Field:
Script Language
Options:
JavaScript
(default for backward compatibility)Python
(newly introduced)


π‘ Use Case
Choose "Python" when you want to leverage Pythonβs expressive syntax and advanced computation libraries for policy logic.
2. Python Scripting Support
Guardian now supports Python as a language for defining business logic in Custom Logic blocks.
β
Capabilities
Execute Python scripts directly as part of policy execution.
Access context variables and input data in Python syntax.
Perform conditional logic, calculations, or transformations using Python.
π Example
pythonCopyEdit# Sample Python logic inside Custom Logic block
if document['type'] == 'Certificate':
document['status'] = 'Verified'
Python code is sandboxed and only has access to allowed libraries/packages pre-installed in the Guardian environment.
3. VC Document Schema Enhancement: guardianVersion
guardianVersion
A new default field has been introduced in all Verifiable Credential document schemas: guardianVersion
.
π Purpose
This field helps track the Guardian system version that was used to generate or interact with the VC. It is especially useful when managing backward compatibility and knowing which Python packages and versions were available during execution.
π Field Details
Field Name:
guardianVersion
Type:
string
Format: Semantic versioning (e.g.,
"3.4.1"
)Automatically populated? β Yes

Last updated