To set a chain variable using python
Code:
chain.set_chain_vars({'variable_name': 'variable_value'})
To retrieve the variable using python:
Code:
chain.chain_vars.get('variable_name', '')
To retrieve the variable using calibre template language:
Code:
program:
my_retrieved_variable = globals(variable_name)
If you want to set a chain variable without using python, you can use the Chain Variables action.