webmcp
diff framework/env/execute/_add_filters_by_path.lua @ 0:9fdfb27f8e67
Version 1.0.0
author | jbe/bsw |
---|---|
date | Sun Oct 25 12:00:00 2009 +0100 (2009-10-25) |
parents | |
children | a54cc7dcabf1 |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/framework/env/execute/_add_filters_by_path.lua Sun Oct 25 12:00:00 2009 +0100 1.3 @@ -0,0 +1,25 @@ 1.4 +function execute._add_filters_by_path(filter_list, ...) 1.5 + local full_path = encode.file_path(request.get_app_basepath(), "app", ...) 1.6 + local relative_path = encode.file_path("", ...) 1.7 + local filter_names = os.listdir(full_path) 1.8 + if filter_names then 1.9 + table.sort(filter_names) -- not really neccessary, due to sorting afterwards 1.10 + for i, filter_name in ipairs(filter_names) do 1.11 + if string.find(filter_name, "%.lua$") then 1.12 + if filter_list[filter_name] then 1.13 + error('More than one filter is named "' .. filter_name .. '".') 1.14 + end 1.15 + table.insert(filter_list, filter_name) 1.16 + filter_list[filter_name] = function() 1.17 + trace.enter_filter{ 1.18 + path = encode.file_path(relative_path, filter_name) 1.19 + } 1.20 + execute.file_path{ 1.21 + file_path = encode.file_path(full_path, filter_name) 1.22 + } 1.23 + trace.execution_return() 1.24 + end 1.25 + end 1.26 + end 1.27 + end 1.28 +end