Browse Source

[trac384] check if a list value exists with 'go'

Jelte Jansen 14 years ago
parent
commit
05f49a9371
2 changed files with 14 additions and 6 deletions
  1. 5 6
      src/bin/bindctl/bindcmd.py
  2. 9 0
      src/lib/python/isc/config/config_data.py

+ 5 - 6
src/bin/bindctl/bindcmd.py

@@ -387,7 +387,6 @@ class BindCmdInterpreter(Cmd):
                 print("Error: " + str(dnfe))
             except KeyError as ke:
                 print("Error: missing " + str(ke))
-                raise ke
         else:
             self.apply_cmd(cmd)
 
@@ -669,11 +668,11 @@ class BindCmdInterpreter(Cmd):
                 new_location, a, b = new_location.rpartition("/")
             else:
                 new_location += "/" + id_part
-                # check if exists, if not, revert and error
-                v = self.config_data.find_spec_part(new_location)
-                if v is None:
-                    print("Error: " + identifier + " not found")
-                    return
+        # check if exists, if not, revert and error
+        v,d = self.config_data.get_value(new_location)
+        if v is None:
+            print("Error: " + identifier + " not found")
+            return
 
         self.location = new_location
 

+ 9 - 0
src/lib/python/isc/config/config_data.py

@@ -405,6 +405,15 @@ class MultiConfigData:
                                 return isc.cc.data.find(list_value, rest_of_id)
                             else:
                                 return list_value
+                    else:
+                        # we do have a non-default list, see if our indices
+                        # exist
+                        for i in list_indices:
+                            if i < len(list_value):
+                                list_value = list_value[i]
+                            else:
+                                # out of range, return None
+                                return None
                     
             spec = find_spec_part(self._specifications[module].get_config_spec(), id)
             if 'item_default' in spec: