webmcp
annotate framework/env/slot/dump_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 |
| rev | line source |
|---|---|
| jbe/bsw@0 | 1 --[[-- |
| jbe/bsw@0 | 2 blob = -- string for later usage with slot.restore_all(...) |
| jbe/bsw@0 | 3 slot.dump_all() |
| jbe/bsw@0 | 4 |
| jbe/bsw@0 | 5 Returns a single string, containing all slot contents. The result of this function can be used to restore all slots after a 303 redirect. This is done automatically by the WebMCP using slot.restore_all(...). If the result of this function is an empty string, then all slots are empty. |
| jbe/bsw@0 | 6 |
| jbe/bsw@0 | 7 --]]-- |
| jbe/bsw@0 | 8 |
| jbe/bsw@0 | 9 local function encode(str) |
| jbe/bsw@0 | 10 return ( |
| jbe/bsw@0 | 11 string.gsub( |
| jbe/bsw@0 | 12 str, |
| jbe/bsw@0 | 13 "[=;%[%]]", |
| jbe/bsw@0 | 14 function(char) |
| jbe/bsw@0 | 15 if char == "=" then return "[eq]" |
| jbe/bsw@0 | 16 elseif char == ";" then return "[s]" |
| jbe/bsw@0 | 17 elseif char == "[" then return "[o]" |
| jbe/bsw@0 | 18 elseif char == "]" then return "[c]" |
| jbe/bsw@0 | 19 else end |
| jbe/bsw@0 | 20 end |
| jbe/bsw@0 | 21 ) |
| jbe/bsw@0 | 22 ) |
| jbe/bsw@0 | 23 end |
| jbe/bsw@0 | 24 |
| jbe/bsw@0 | 25 function slot.dump_all() |
| jbe/bsw@0 | 26 local blob_parts = {} |
| jbe/bsw@0 | 27 for key in pairs(slot._data) do |
| jbe/bsw@0 | 28 if type(key) == "string" then |
| jbe/bsw@0 | 29 local value = slot.get_content(key) |
| jbe/bsw@0 | 30 if value ~= "" then |
| jbe/bsw@0 | 31 blob_parts[#blob_parts + 1] = encode(key) .. "=" .. encode(value) |
| jbe/bsw@0 | 32 end |
| jbe/bsw@0 | 33 end |
| jbe/bsw@0 | 34 end |
| jbe/bsw@0 | 35 return table.concat(blob_parts, ";") |
| jbe/bsw@0 | 36 end |