1 from PLC.Faults import *
2 from PLC.Method import Method
3 from PLC.Parameter import Parameter, Mixed
4 from PLC.Attributes import Attribute, Attributes
5 from PLC.Auth import PasswordAuth
7 can_update = lambda (field, value): field in \
8 ['description', 'min_role_id']
10 class UpdateAttribute(Method):
12 Updates the parameters of an existing attribute with the values in
15 Returns 1 if successful, faults otherwise.
20 update_fields = dict(filter(can_update, Attribute.fields.items()))
24 Mixed(Attribute.fields['attribute_id'],
25 Attribute.fields['name']),
29 returns = Parameter(int, '1 if successful')
31 def call(self, auth, attribute_id_or_name, attribute_fields):
32 attribute_fields = dict(filter(can_update, attribute_fields.items()))
34 attributes = Attributes(self.api, [attribute_id_or_name]).values()
36 raise PLCInvalidArgument, "No such attribute"
37 attribute = attributes[0]
39 attribute.update(attribute_fields)