Revert UVL optimizations
[project/luci.git] / libs / uvl / luasrc / uvl.lua
index 1b430af10c358fed993ba5d1ccaf1ac37af4497c..98e7dfba6a249a32b886781e4a2e2c0823583035 100644 (file)
@@ -390,8 +390,8 @@ function UVL.read_scheme( self, scheme, alias )
                        self.packages[scheme] = sc()
                        return true
                else
-                       return false, so:error(ERR.SME_READ(so,file))
-               end      
+                       return false, so:error(ERR.SME_READ(so,bc))
+               end
        end
 end
 
@@ -630,7 +630,7 @@ function UVL._read_scheme_parts( self, scheme, schemes )
                                local oo = so:option(r[3])
                                local eo = oo:enum(v.value)
 
-                               if t.type ~= "enum" then
+                               if t.type ~= "enum" and t.type ~= "reference" then
                                        return false, scheme:error(ERR.SME_EBADTYPE(eo))
                                end
 
@@ -813,7 +813,17 @@ end
 uvlitem = luci.util.class()
 
 function uvlitem.cid(self)
-       return table.concat( self.cref, '.' )
+       if #self.cref == 1 then
+               return self.cref[1]
+       else
+               local r = { unpack(self.cref) }
+               local c = self.c
+               if c and c[r[2]] and c[r[2]]['.anonymous'] and c[r[2]]['.index'] then
+                       r[2] = '@' .. c[r[2]]['.type'] ..
+                              '[' .. tostring(c[r[2]]['.index']) .. ']'
+               end
+               return table.concat( r, '.' )
+       end
 end
 
 function uvlitem.sid(self)
@@ -1119,7 +1129,7 @@ end
 --- Get the value of this option.
 -- @return     The associated configuration value
 function option.value(self)
-       local v = self:config()
+       local v = self:config() or self:scheme('default')
        if v and self:scheme('multival') then
                v = luci.util.split( v, "%s+", nil, true )
        end