revised type-checking on taggable classes - previous code would reject any tag
[plcapi.git] / PLC / Methods / AddInterface.py
index 662d7fd..69e92ec 100644 (file)
@@ -12,7 +12,7 @@ from PLC.InterfaceTags import InterfaceTags
 from PLC.Methods.AddInterfaceTag import AddInterfaceTag
 from PLC.Methods.UpdateInterfaceTag import UpdateInterfaceTag
 
-can_update = ['interface_id', 'node_id']
+cannot_update = ['interface_id', 'node_id']
 
 class AddInterface(Method):
     """
@@ -33,7 +33,8 @@ class AddInterface(Method):
 
     roles = ['admin', 'pi', 'tech']
 
-    accepted_fields = Row.accepted_fields(can_update, [Interface.fields,Interface.tags], exclude=True)
+    accepted_fields = Row.accepted_fields(cannot_update, Interface.fields, exclude=True)
+    accepted_fields.update(Interface.tags)
 
     accepts = [
         Auth(),
@@ -47,9 +48,10 @@ class AddInterface(Method):
     
     def call(self, auth, node_id_or_hostname, interface_fields):
 
-        interface_fields = Row.check_fields (interface_fields, self.accepted_fields)
-
         [native,tags,rejected]=Row.split_fields(interface_fields,[Interface.fields,Interface.tags])
+
+        # type checking
+        native = Row.check_fields (native, self.accepted_fields)
         if rejected:
             raise PLCInvalidArgument, "Cannot add Interface with column(s) %r"%rejected