Commits

Daniel Poelzleithner  committed e31af86

add id/params support

  • Participants
  • Parent commits 1cd9e69

Comments (0)

Files changed (1)

File framework/env/execute/load_chunk.lua

   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 
   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