* CBI: updates
[project/luci.git] / src / ffluci / util.lua
index b219be130e890af1c521fcce30e32cbe7ad73bb9..38f33a20d46f224cddf049d7ffab548c1d8bfb9e 100644 (file)
@@ -36,7 +36,10 @@ function class(base)
                setmetatable(inst, {__index = class})
                
                if inst.__init__ then
-                       inst:__init__(...)
+                       local stat, err = pcall(inst.__init__, inst, ...)
+                       if not stat then
+                               error(err)
+                       end
                end
                
                return inst
@@ -138,6 +141,11 @@ function resfenv(f)
 end 
 
 
+-- Returns the Haserl unique sessionid
+function sessionid()
+       return ENV.SESSIONID
+end
+
 -- Updates the scope of f with "extscope"
 function updfenv(f, extscope)
        local scope = getfenv(f)
@@ -161,7 +169,7 @@ function validate(value, cast_number, cast_int, valid)
        if type(valid) == "function" then
                value = valid(value)
        elseif type(valid) == "table" then
-               if not ffluci.util.contains(valid, value) then
+               if not contains(valid, value) then
                        value = nil
                end
        end