webmcp
view framework/env/slot/restore_all.lua @ 2:72860d232f32
Version 1.0.2
Fixed bug with explicit garbage collection (requests > 256kB caused an error)
Views prefixed with an underscore can't be called externally
ui.paginate now displays the last page, if the selected page number is too high.
Fixed bug with explicit garbage collection (requests > 256kB caused an error)
Views prefixed with an underscore can't be called externally
ui.paginate now displays the last page, if the selected page number is too high.
author | jbe/bsw |
---|---|
date | Thu Dec 10 12:00:00 2009 +0100 (2009-12-10) |
parents | 9fdfb27f8e67 |
children |
line source
1 --[[--
2 slot.restore_all(
3 blob -- string as returned by slot.dump_all()
4 )
6 Restores all slots using a string created by slot.dump_all().
8 --]]--
10 local function decode(str)
11 return (
12 string.gsub(
13 str,
14 "%[[a-z]+%]",
15 function(char)
16 if char == "[eq]" then return "="
17 elseif char == "[s]" then return ";"
18 elseif char == "[o]" then return "["
19 elseif char == "[c]" then return "]"
20 else end
21 end
22 )
23 )
24 end
26 function slot.restore_all(blob)
27 slot.reset_all()
28 for encoded_key, encoded_value in string.gmatch(blob, "([^=;]*)=([^=;]*)") do
29 local key, value = decode(encoded_key), decode(encoded_value)
30 slot._data[key].string_fragments = { value }
31 end
32 end