Performing Genshi ScriptsΒΆ

ACR provides a way to perform small python scripts and generate pages on the fly using the genshi template engine. This can be used to implement small web applications, for more complex functions using plugins is suggested.

To create a script which can later be performed you must go to Unbound Entities and press the Create Genshi Script button. This will create a new unbound slice (a slice without a page) which can then be performed using /acr/perform/{slice_name} url. Slices bound to a page cannot be performed.

Refer to Genshi for more details about the objects available inside a genshi script.


import random
filter = {}

if acr.request.GET.get('create'):
    created = acr.depot.create('depot_test', {'path':acr.request.path, 'num':random.randint(1, 10)})
elif acr.request.GET.get('delete'):
    acr.depot.delete('depot_test', acr.request.GET['delete'])
elif acr.request.GET.get('search'):
    filter = {'num':acr.request.GET['search']}

<a href="?create=1">Create</a><br/>
<py:for each="entry in acr.depot.lookup('depot_test', filter)">
   <a href="?search=${['num']}">search</a> ${entry.object_id} - ${} <a href="?delete=${entry.object_id}">delete</a><br/>