webmcp

view framework/env/slot/dump_all.lua @ 23:3a6fe8663b26

Code cleanup and documentation added; Year in copyright notice changed to 2009-2010

Details:
- Changed quoting style in auth.openid.xrds_document{...}
- Fixed documentation for auth.openid.initiate{...}
- Added documentation for mondelefant
- Code-cleanup in mondelefant:
-- removed unneccessary lines "rows = PQntuples(res); cols = PQnfields(res);"
-- avoided extra copy of first argument (self) in mondelefant_conn_query
-- no rawget in meta-method "__index" of database result lists and objects
-- removed unreachable "return 0;" in meta-method "__newindex" of database result lists and objects
- Year in copyright notice changed to 2009-2010
- Version string changed to "1.1.1"
author jbe
date Fri Jun 04 19:00:34 2010 +0200 (2010-06-04)
parents 9fdfb27f8e67
children
line source
1 --[[--
2 blob = -- string for later usage with slot.restore_all(...)
3 slot.dump_all()
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.
7 --]]--
9 local function encode(str)
10 return (
11 string.gsub(
12 str,
13 "[=;%[%]]",
14 function(char)
15 if char == "=" then return "[eq]"
16 elseif char == ";" then return "[s]"
17 elseif char == "[" then return "[o]"
18 elseif char == "]" then return "[c]"
19 else end
20 end
21 )
22 )
23 end
25 function slot.dump_all()
26 local blob_parts = {}
27 for key in pairs(slot._data) do
28 if type(key) == "string" then
29 local value = slot.get_content(key)
30 if value ~= "" then
31 blob_parts[#blob_parts + 1] = encode(key) .. "=" .. encode(value)
32 end
33 end
34 end
35 return table.concat(blob_parts, ";")
36 end

Impressum / About Us