* luci/libs: uvl: implement "named" flag for schemes
authorJo-Philipp Wich <jow@openwrt.org>
Sun, 24 Aug 2008 16:09:02 +0000 (16:09 +0000)
committerJo-Philipp Wich <jow@openwrt.org>
Sun, 24 Aug 2008 16:09:02 +0000 (16:09 +0000)
libs/uvl/luasrc/uvl.lua

index a9359d0c35efb2eca370df2e3dd593cbe21bc9a2..bc22c81f878546b538d41025dca5e29589cda816 100644 (file)
@@ -298,6 +298,13 @@ end
 function UVL._validate_section( self, section )
 
        if section:values() then
+               if section:section().named == true and
+                  section:values()['.anonymous'] == true
+               then
+                       return false, self.log.section_error( section,
+                               'The section of type "' .. section:sid() .. '" is stored ' ..
+                               'anonymously in config but must be named' )
+               end
 
                for _, v in ipairs(section:variables()) do
                        local ok, err = self:_validate_option( v )
@@ -500,7 +507,9 @@ function UVL._read_scheme_parts( self, scheme, schemes )
                                                                'dependency specification in "%s"',
                                                                v.name or '<nil>', scheme or '<nil>', k
                                                        )
-                                               elseif k == "dynamic" or k == "unique" or k == "required" then
+                                               elseif k == "dynamic" or k == "unique" or
+                                                      k == "required" or k == "named"
+                                               then
                                                        s[k] = _bool(v2)
                                                else
                                                        s[k] = v2
@@ -511,6 +520,7 @@ function UVL._read_scheme_parts( self, scheme, schemes )
                                s.dynamic  = s.dynamic  or false
                                s.unique   = s.unique   or false
                                s.required = s.required or false
+                               s.named    = s.named    or false
                        end
                end
        end