webmcp
diff framework/env/execute/file_path.lua @ 352:2b5bdf9028fb
Code cleanup and performance improvements regarding 404 check; Deprecated encode.action_file_path{...} and encode.view_file_path{...}
| author | jbe |
|---|---|
| date | Thu Mar 26 16:40:04 2015 +0100 (2015-03-26) |
| parents | ba68ef9e7c90 |
| children |
line diff
1.1 --- a/framework/env/execute/file_path.lua Thu Mar 26 16:38:30 2015 +0100 1.2 +++ b/framework/env/execute/file_path.lua Thu Mar 26 16:40:04 2015 +0100 1.3 @@ -1,20 +1,29 @@ 1.4 --[[-- 1.5 -status_code = -- status code returned by the executed lua file (a string) 1.6 +status_code = -- status code returned by the executed lua file (a string) 1.7 execute.file_path{ 1.8 - file_path = file_path, -- path to a Lua source or byte-code file 1.9 - id = id, -- id to be returned by param.get_id(...) during execution 1.10 - params = params -- parameters to be returned by param.get(...) during execution 1.11 + file_path = file_path, -- path to a Lua source or byte-code file 1.12 + id = id, -- id to be returned by param.get_id(...) during execution 1.13 + params = params, -- parameters to be returned by param.get(...) during execution 1.14 + test_existence = test_existence -- do not execute view or action but only check if it exists 1.15 } 1.16 1.17 -This function loads and executes a lua file specified by a given path. If an "id" or "params" are provided, the param.get_id(...) and/or param.get(...) functions will return the provided values during execution. The lua routine must return true, false, nil or a string. In case of true or nil, this function returns the string "ok", in case of false, this function returns "error", otherwise the string returned by the lua routine will be returned by this function as well. 1.18 +This function loads and executes a Lua file specified by a given path. If an "id" or "params" are provided, the param.get_id(...) and/or param.get(...) functions will return the provided values during execution. The Lua routine must return true, false, nil or a string. In case of true or nil, this function returns the string "ok", in case of false, this function returns "error", otherwise the string returned by the lua routine will be returned by this function as well. 1.19 1.20 --]]-- 1.21 1.22 function execute.file_path(args) 1.23 local file_path = args.file_path 1.24 - local id = args.id 1.25 - local params = args.params 1.26 - local func, load_errmsg = assert(loadcached(file_path)) 1.27 + local test = args.test_existence 1.28 + if test then 1.29 + if loadcached(file_path) then 1.30 + return true 1.31 + else 1.32 + return false 1.33 + end 1.34 + end 1.35 + local id = args.id 1.36 + local params = args.params 1.37 + local func = assert(loadcached(file_path)) 1.38 if id or params then 1.39 param.exchange(id, params) 1.40 end