From: Mark Huang <mlhuang@cs.princeton.edu>
Date: Fri, 13 Oct 2006 20:07:29 +0000 (+0000)
Subject: - silently remove fields that can't be updated from slice_fields, for
X-Git-Tag: pycurl-7_13_1~575
X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;h=f19550395a204de8b7232919503339b546015295;p=plcapi.git

- silently remove fields that can't be updated from slice_fields, for
  backward compatibility with SliceAdd
---

diff --git a/PLC/Methods/UpdateAttribute.py b/PLC/Methods/UpdateAttribute.py
index cffc9da6..2ecfe45f 100644
--- a/PLC/Methods/UpdateAttribute.py
+++ b/PLC/Methods/UpdateAttribute.py
@@ -4,18 +4,19 @@ from PLC.Parameter import Parameter, Mixed
 from PLC.Attributes import Attribute, Attributes
 from PLC.Auth import PasswordAuth
 
+can_update = lambda (field, value): field in \
+             ['description', 'min_role_id']
+
 class UpdateAttribute(Method):
     """
     Updates the parameters of an existing attribute with the values in
-    update_fields.
+    attribute_fields.
 
     Returns 1 if successful, faults otherwise.
     """
 
     roles = ['admin']
 
-    can_update = lambda (field, value): field in \
-                 ['description', 'min_role_id']
     update_fields = dict(filter(can_update, Attribute.fields.items()))
 
     accepts = [
@@ -27,16 +28,15 @@ class UpdateAttribute(Method):
 
     returns = Parameter(int, '1 if successful')
 
-    def call(self, auth, attribute_id_or_name, update_fields):
-        if filter(lambda field: field not in self.update_fields, update_fields):
-            raise PLCInvalidArgument, "Invalid field specified"
+    def call(self, auth, attribute_id_or_name, attribute_fields):
+        attribute_fields = dict(filter(can_update, attribute_fields.items()))
 
         attributes = Attributes(self.api, [attribute_id_or_name]).values()
         if not attributes:
             raise PLCInvalidArgument, "No such attribute"
         attribute = attributes[0]
 
-        attribute.update(update_fields)
+        attribute.update(attribute_fields)
 
         attribute.sync()