webmcp
view framework/env/slot/reset_all.lua @ 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 | 9fdfb27f8e67 |
| children | 09f749330d13 |
line source
1 --[[--
2 slot.reset_all{
3 except = except, -- Reset all slots, except slots named in this list
4 }
6 Calling this function resets all slots to be empty.
8 --]]--
10 function slot.reset_all(args)
11 local saved = {}
12 if args and args.except then
13 for i,key in ipairs(args.except) do
14 saved[key] = slot._data[key]
15 end
16 end
17 slot._data = setmetatable({}, slot._data_metatable)
18 if saved then
19 for key,value in pairs(saved) do
20 slot._data[key] = value
21 end
22 end
23 end
