git://git.onelab.eu
/
plcapi.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
revised type-checking on taggable classes - previous code would reject any tag
[plcapi.git]
/
PLC
/
Methods
/
AddInterface.py
diff --git
a/PLC/Methods/AddInterface.py
b/PLC/Methods/AddInterface.py
index
662d7fd
..
69e92ec
100644
(file)
--- a/
PLC/Methods/AddInterface.py
+++ b/
PLC/Methods/AddInterface.py
@@
-12,7
+12,7
@@
from PLC.InterfaceTags import InterfaceTags
from PLC.Methods.AddInterfaceTag import AddInterfaceTag
from PLC.Methods.UpdateInterfaceTag import UpdateInterfaceTag
from PLC.Methods.AddInterfaceTag import AddInterfaceTag
from PLC.Methods.UpdateInterfaceTag import UpdateInterfaceTag
-can_update = ['interface_id', 'node_id']
+can
not
_update = ['interface_id', 'node_id']
class AddInterface(Method):
"""
class AddInterface(Method):
"""
@@
-33,7
+33,8
@@
class AddInterface(Method):
roles = ['admin', 'pi', 'tech']
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(),
accepts = [
Auth(),
@@
-47,9
+48,10
@@
class AddInterface(Method):
def call(self, auth, node_id_or_hostname, interface_fields):
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])
[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
if rejected:
raise PLCInvalidArgument, "Cannot add Interface with column(s) %r"%rejected