Add functions to dict and pass as an argument to globals for rendering:
render = web.template.render('templates/', globals={'sum': sum})
Then in your template, you can simply use it:
$def with (numbers)
<h1>Numbers add to $sum(numbers)</h1>
source
share