Lua scripting¶
Coralillo uses a few lua scripts to atomically run certain operations. These can be accessed through the engine’s lua object. Here are the available scripts:
-
engine.lua.drop(args=[pattern])¶ Deletes all keys matching
patternfrom the database. Specially useful in tests.
-
engine.lua.allow(args=[objspec], keys=[allow_key])¶ Adds objspec to the permission tree stored at
allow_key
Script registering¶
You can add your own scripts using Coralillo’s lua interface like this:
from coralillo import Engine
eng = Engine()
script = 'return ARGV[1]'
eng.lua.register('my_script', script)
assert eng.lua.my_script(args=['hello']) == b'hello'
-
Lua.register(scriptname, scriptbody)¶ Registers script defined by
scriptbody(a string) so it is accessible through theluainterface of the engine under the namescriptname.