webmcp
diff framework/env/execute/filtered_action.lua @ 0:9fdfb27f8e67
Version 1.0.0
author | jbe/bsw |
---|---|
date | Sun Oct 25 12:00:00 2009 +0100 (2009-10-25) |
parents | |
children | eb3e236d261d |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/framework/env/execute/filtered_action.lua Sun Oct 25 12:00:00 2009 +0100 1.3 @@ -0,0 +1,39 @@ 1.4 +--[[-- 1.5 +action_status = -- status code returned by the action (a string) 1.6 +execute.filtered_action{ 1.7 + module = module, -- module name of the action to be executed 1.8 + action = action, -- name of the action to be executed 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 +} 1.12 + 1.13 +Executes an action with associated filters. 1.14 +This function is only used by by the webmcp.lua file in the cgi-bin/ directory. 1.15 + 1.16 +--]]-- 1.17 + 1.18 +function execute.filtered_action(args) 1.19 + local filters = {} 1.20 + local function add_by_path(...) 1.21 + execute._add_filters_by_path(filters, ...) 1.22 + end 1.23 + add_by_path("_filter") 1.24 + add_by_path("_filter_action") 1.25 + add_by_path(request.get_app_name(), "_filter") 1.26 + add_by_path(request.get_app_name(), "_filter_action") 1.27 + add_by_path(request.get_app_name(), args.module, "_filter") 1.28 + add_by_path(request.get_app_name(), args.module, "_filter_action") 1.29 + table.sort(filters) 1.30 + for idx, filter_name in ipairs(filters) do 1.31 + filters[idx] = filters[filter_name] 1.32 + filters[filter_name] = nil 1.33 + end 1.34 + local result 1.35 + execute.multi_wrapped( 1.36 + filters, 1.37 + function() 1.38 + result = execute.action(args) 1.39 + end 1.40 + ) 1.41 + return result 1.42 +end