# HG changeset patch # User Daniel Poelzleithner # Date 1286245608 -7200 # Node ID e31af860e97cc50576e4c4255dee79596f20eb2b # Parent 1cd9e69b85cb7f70b7bd488c6d04562d700f692e add id/params support diff -r 1cd9e69b85cb -r e31af860e97c framework/env/execute/load_chunk.lua --- a/framework/env/execute/load_chunk.lua Tue Oct 05 02:34:04 2010 +0200 +++ b/framework/env/execute/load_chunk.lua Tue Oct 05 04:26:48 2010 +0200 @@ -5,6 +5,8 @@ app = app, -- app name to use or the current will be used module = module, -- module where chunk is located chunk = chunk -- filename of lua file to load + id = id, -- id to be returned by param.get_id(...) during execution + params = params -- parameters to be returned by param.get(...) during execution } This function loads and executes a lua file specified by a given path or constructs @@ -17,16 +19,29 @@ local app = args.app local module = args.module local chunk = args.chunk + local id = args.id + local params = args.params app = app or request.get_app_name() file_path = file_path or encode.file_path(request.get_app_basepath(), 'app', app, module, chunk) + local func, load_errmsg = loadfile(file_path) if not func then error('Could not load file "' .. file_path .. '": ' .. load_errmsg) end + + if id or params then + param.exchange(id, params) + end + local result = func() + + if id or params then + param.restore() + end + return result end