comparison mod_pastebin/mod_pastebin.lua @ 517:f866325305ed

mod_pastebin: Make last commit work (also set on restore)
author Matthew Wild <mwild1@gmail.com>
date Wed, 21 Dec 2011 10:38:44 +0000
parents 3d3687fef751
children 9c2eea631811
comparison
equal deleted inserted replaced
516:3d3687fef751 517:f866325305ed
141 base_url = base_url or ("http://"..module:get_host()..(port ~= 80 and (":"..port) or "").."/"..base.."/"); 141 base_url = base_url or ("http://"..module:get_host()..(port ~= 80 and (":"..port) or "").."/"..base.."/");
142 142
143 httpserver.new{ port = port, base = base, handler = handle_request, ssl = ssl } 143 httpserver.new{ port = port, base = base, handler = handle_request, ssl = ssl }
144 end 144 end
145 145
146 function module.load() 146 local function set_pastes_metatable()
147 if expire_after == 0 then 147 if expire_after == 0 then
148 local dm = require "util.datamanager"; 148 local dm = require "util.datamanager";
149 setmetatable(pastes, { 149 setmetatable(pastes, {
150 __index = function (pastes, id) 150 __index = function (pastes, id)
151 if type(id) == "string" then 151 if type(id) == "string" then
161 else 161 else
162 setmetatable(pastes, nil); 162 setmetatable(pastes, nil);
163 end 163 end
164 end 164 end
165 165
166 module.load = set_pastes_metatable;
167
166 function module.save() 168 function module.save()
167 return { pastes = pastes }; 169 return { pastes = pastes };
168 end 170 end
169 171
170 function module.restore(data) 172 function module.restore(data)
171 pastes = data.pastes or pastes; 173 pastes = data.pastes or pastes;
174 set_pastes_metatable();
172 end 175 end