Initialization problem fixed in Post; Re-publishing the published profile did
authorTimm S. Mueller <tmueller@neoscientists.org>
Mon, 06 Oct 2008 21:36:21 +0200
changeset 24771a5ca44a68e
parent 246 9378039084bd
child 248 d00981e0d1de
Initialization problem fixed in Post; Re-publishing the published profile did
not work, corrected; updated the debug class
cgi-bin/tek/class/cgi/post.lua
cgi-bin/tek/class/loona.lua
cgi-bin/tek/lib/debug.lua
     1.1 --- a/cgi-bin/tek/class/cgi/post.lua	Sat Sep 13 15:57:41 2008 +0200
     1.2 +++ b/cgi-bin/tek/class/cgi/post.lua	Mon Oct 06 21:36:21 2008 +0200
     1.3 @@ -14,7 +14,7 @@
     1.4  local min = math.min
     1.5  
     1.6  module("tek.class.cgi.post", tek.class)
     1.7 -_VERSION = "Post 1.4"
     1.8 +_VERSION = "Post 1.5"
     1.9  local Post = _M
    1.10  
    1.11  -------------------------------------------------------------------------------
    1.12 @@ -114,6 +114,9 @@
    1.13  	self.content_type = false
    1.14  	self.maxinput = self.maxinput or false
    1.15  	self.maxfilesize = self.maxfilesize or false
    1.16 +	self.inputfile = self.inputfile or false
    1.17 +	self.bytesleft = self.bytesleft or false
    1.18 +	self.boundary = self.boundary or false
    1.19  	return Class.new(class, self)
    1.20  end
    1.21  
     2.1 --- a/cgi-bin/tek/class/loona.lua	Sat Sep 13 15:57:41 2008 +0200
     2.2 +++ b/cgi-bin/tek/class/loona.lua	Mon Oct 06 21:36:21 2008 +0200
     2.3 @@ -37,7 +37,7 @@
     2.4  -------------------------------------------------------------------------------
     2.5  
     2.6  module("tek.class.loona", tek.class)
     2.7 -_VERSION = "LOona Class 5.4"
     2.8 +_VERSION = "LOona Class 5.5"
     2.9  
    2.10  -------------------------------------------------------------------------------
    2.11  --	Markup:
    2.12 @@ -1513,7 +1513,7 @@
    2.13  			-- Publish profile
    2.14  
    2.15  			local c = self:checkprofilename(self.args.publishprofile:lower())
    2.16 -			if c ~= self.pubprofile then
    2.17 +			if c ~= self.pubprofile or self.config.editablepubprofile then
    2.18  				if self.args.actionconfirm then
    2.19  					self:publishprofile(c)
    2.20  					save = true
     3.1 --- a/cgi-bin/tek/lib/debug.lua	Sat Sep 13 15:57:41 2008 +0200
     3.2 +++ b/cgi-bin/tek/lib/debug.lua	Mon Oct 06 21:36:21 2008 +0200
     3.3 @@ -50,7 +50,7 @@
     3.4  local unpack = unpack
     3.5  
     3.6  module "tek.lib.debug"
     3.7 -_VERSION = "Debug 4.0"
     3.8 +_VERSION = "Debug 4.1"
     3.9  
    3.10  -- symbolic:
    3.11  
    3.12 @@ -62,7 +62,7 @@
    3.13  
    3.14  -- global defaults:
    3.15  
    3.16 -level = ERROR
    3.17 +level = INFO
    3.18  out = stderr
    3.19  wrout = function(...) out:write(...) end
    3.20  
    3.21 @@ -140,40 +140,58 @@
    3.22  	stderr:write('To redirect the output, e.g.:\n')
    3.23  	stderr:write('  tek.lib.debug.out = io.open("logfile", "w")\n')
    3.24  	stderr:write('To dump a table, e.g.:\n')
    3.25 -	stderr:write('  tek.lib.debug.dump("app", app)\n')
    3.26 +	stderr:write('  tek.lib.debug.dump(app)\n')
    3.27  	stderr:write('Use "cont" to continue.\n')
    3.28  	debug.debug()
    3.29  end
    3.30  
    3.31  -------------------------------------------------------------------------------
    3.32 ---	dump(name, table): Dump a table
    3.33 +--	dump(table): Dump a table as Lua source using {{out}} as the output
    3.34 +--	stream. Cyclic references are silently dropped.
    3.35  -------------------------------------------------------------------------------
    3.36  
    3.37 -local function basicSerialize(o)
    3.38 -	if type(o) == "string" then
    3.39 -		return ("%q"):format(o)
    3.40 -	elseif type(o) == "userdata" then
    3.41 -		return "<userdata>"
    3.42 -	end
    3.43 -	return tostring(o)
    3.44 +local function encodenonascii(c)
    3.45 +	return ("\\%03d"):format(c:byte())
    3.46  end
    3.47  
    3.48 -function dump(name, value, saved)
    3.49 -	saved = saved or {}       -- initial value
    3.50 -	wrout(name, " = ")
    3.51 -	local t = type(value)
    3.52 -	if t == "table" then
    3.53 -		if saved[value] then    -- value already saved?
    3.54 -			wrout(saved[value], "\n")
    3.55 -		else
    3.56 -			saved[value] = name   -- save name for next time
    3.57 -			wrout("{}\n")
    3.58 -			for k,v in pairs(value) do      -- save its fields
    3.59 -				local fieldname = ("%s[%s]"):format(name, basicSerialize(k))
    3.60 -				dump(fieldname, v, saved)
    3.61 +local function encode(s)
    3.62 +	return s:gsub('([%z\001-\031\092"])', encodenonascii)
    3.63 +end
    3.64 +
    3.65 +local function dumpr(tab, indent, outfunc, saved)
    3.66 +	saved[tab] = tab
    3.67 +	local is = ("\t"):rep(indent)
    3.68 +	for key, val in pairs(tab) do
    3.69 +		if not saved[val] then
    3.70 +			outfunc(is)
    3.71 +			local t = type(key)
    3.72 +			if t == "number" or t == "boolean" then
    3.73 +				outfunc('[' .. tostring(key) .. '] = ')
    3.74 +			elseif t == "string" then
    3.75 +				if key:match("[^%a_]") then
    3.76 +					outfunc('["' .. encode(key) .. '"] = ')
    3.77 +				else
    3.78 +					outfunc(key .. ' = ')
    3.79 +				end
    3.80 +			else
    3.81 +				outfunc('["' .. tostring(key) .. '"] = ')
    3.82 +			end
    3.83 +			t = type(val)
    3.84 +			if t == "table" then
    3.85 +				outfunc('{\n')
    3.86 +				dumpr(val, indent + 1, outfunc, saved)
    3.87 +				outfunc(is .. '},\n')
    3.88 +			elseif t == "string" then
    3.89 +				outfunc('"' .. encode(val) .. '",\n')
    3.90 +			elseif t == "number" or t == "boolean" then
    3.91 +				outfunc(tostring(val) .. ',\n')
    3.92 +			else
    3.93 +				outfunc('"' .. tostring(val) .. '",\n')
    3.94  			end
    3.95  		end
    3.96 -	else
    3.97 -		wrout(basicSerialize(value), "\n")
    3.98  	end
    3.99  end
   3.100 +
   3.101 +function dump(tab, outf)
   3.102 +	dumpr(tab, 0, outf or wrout, { })
   3.103 +end