webmcp

diff libraries/atom/atom.lua @ 1:985024b16520

Version 1.0.1

New feature: JSON requests

Changes in ui.paginate: Current page setting is directly fetched from CGI params, instead of view params

Changed behavior of load methods of atom library to accept nil as input

Bugfixes in mondelefant_atom_connector timestamp(tz) loaders

Added global constant _WEBMCP_VERSION containing a version string
author jbe
date Tue Nov 17 12:00:00 2009 +0100 (2009-11-17)
parents 9fdfb27f8e67
children 3d43a5cf17c1
line diff
     1.1 --- a/libraries/atom/atom.lua	Sun Oct 25 12:00:00 2009 +0100
     1.2 +++ b/libraries/atom/atom.lua	Tue Nov 17 12:00:00 2009 +0100
     1.3 @@ -212,10 +212,10 @@
     1.4  
     1.5  --]]--
     1.6  function boolean:load(str)
     1.7 -  if type(str) ~= "string" then
     1.8 +  if str == nil or str == "" then
     1.9 +    return nil
    1.10 +  elseif type(str) ~= "string" then
    1.11      error("String expected")
    1.12 -  elseif str == "" then
    1.13 -    return nil
    1.14    elseif string.find(str, "^[TtYy1]") then
    1.15      return true
    1.16    elseif string.find(str, "^[FfNn0]") then
    1.17 @@ -244,7 +244,9 @@
    1.18  
    1.19  --]]--
    1.20  function _M.string:load(str)
    1.21 -  if type(str) ~= "string" then
    1.22 +  if str == nil then
    1.23 +    return nil
    1.24 +  elseif type(str) ~= "string" then
    1.25      error("String expected")
    1.26    else
    1.27      return str
    1.28 @@ -270,10 +272,10 @@
    1.29  
    1.30  --]]--
    1.31  function integer:load(str)
    1.32 -  if type(str) ~= "string" then
    1.33 +  if str == nil or str == "" then
    1.34 +    return nil
    1.35 +  elseif type(str) ~= "string" then
    1.36      error("String expected")
    1.37 -  elseif str == "" then
    1.38 -    return nil
    1.39    else
    1.40      local num = tonumber(str)
    1.41      if is_integer(num) then return num else return not_a_number end
    1.42 @@ -308,10 +310,10 @@
    1.43  
    1.44  --]]--
    1.45  function number:load(str)
    1.46 -  if type(str) ~= "string" then
    1.47 +  if str == nil or str == "" then
    1.48 +    return nil
    1.49 +  elseif type(str) ~= "string" then
    1.50      error("String expected")
    1.51 -  elseif str == "" then
    1.52 -    return nil
    1.53    else
    1.54      return tonumber(str) or not_a_number
    1.55    end
    1.56 @@ -463,8 +465,10 @@
    1.57  
    1.58  --]]--
    1.59  function fraction:load(str)
    1.60 -  if str == "" then
    1.61 +  if str == nil or str == "" then
    1.62      return nil
    1.63 +  elseif type(str) ~= "string" then
    1.64 +    error("String expected")
    1.65    else
    1.66      local sign, int = string.match(str, "^(%-?)([0-9]+)$")
    1.67      if sign == "" then return fraction:new(tonumber(int))
    1.68 @@ -877,8 +881,10 @@
    1.69  
    1.70  --]]--
    1.71  function date:load(str)
    1.72 -  if str == "" then
    1.73 +  if str == nil or str == "" then
    1.74      return nil
    1.75 +  elseif type(str) ~= "string" then
    1.76 +    error("String expected")
    1.77    else
    1.78      local year, month, day = string.match(
    1.79        str, "^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$"
    1.80 @@ -1197,8 +1203,10 @@
    1.81  
    1.82  --]]--
    1.83  function timestamp:load(str)
    1.84 -  if str == "" then
    1.85 +  if str == nil or str == "" then
    1.86      return nil
    1.87 +  elseif type(str) ~= "string" then
    1.88 +    error("String expected")
    1.89    else
    1.90      local year, month, day, hour, minute, second = string.match(
    1.91        str,
    1.92 @@ -1418,8 +1426,10 @@
    1.93  
    1.94  --]]--
    1.95  function time:load(str)
    1.96 -  if str == "" then
    1.97 +  if str == nil or str == "" then
    1.98      return nil
    1.99 +  elseif type(str) ~= "string" then
   1.100 +    error("String expected")
   1.101    else
   1.102      local hour, minute, second = string.match(
   1.103        str,

Impressum / About Us