webmcp
changeset 34:e19b0b5c46ba
allow execptions an slot.reset_all()
this is usefull when an error is detected deep into a view where you want redirect
to something usefull, but still save some slots like notice and error slots
this is usefull when an error is detected deep into a view where you want redirect
to something usefull, but still save some slots like notice and error slots
author | Daniel Poelzleithner <poelzi@poelzi.org> |
---|---|
date | Wed Oct 06 16:14:33 2010 +0200 (2010-10-06) |
parents | fc98e5c6bfab |
children | 81dfcfd960ed |
files | framework/env/slot/reset_all.lua |
line diff
1.1 --- a/framework/env/slot/reset_all.lua Tue Oct 05 05:19:47 2010 +0200 1.2 +++ b/framework/env/slot/reset_all.lua Wed Oct 06 16:14:33 2010 +0200 1.3 @@ -1,10 +1,23 @@ 1.4 --[[-- 1.5 -slot.reset_all() 1.6 +slot.reset_all{ 1.7 + except = except, -- Reset all slots, except slots named in this list 1.8 +} 1.9 1.10 Calling this function resets all slots to be empty. 1.11 1.12 --]]-- 1.13 1.14 -function slot.reset_all() 1.15 +function slot.reset_all(args) 1.16 + local saved = {} 1.17 + if args and args.except then 1.18 + for i,key in ipairs(args.except) do 1.19 + saved[key] = slot._data[key] 1.20 + end 1.21 + end 1.22 slot._data = setmetatable({}, slot._data_metatable) 1.23 + if saved then 1.24 + for key,value in pairs(saved) do 1.25 + slot._data[key] = value 1.26 + end 1.27 + end 1.28 end