1 from PLC.Faults import *
2 from PLC.Method import Method
3 from PLC.Parameter import Parameter, Mixed
4 from PLC.Messages import Message, Messages
5 from PLC.Auth import Auth
7 can_update = lambda (field, value): field in \
8 ['template', 'enabled']
10 class UpdateMessage(Method):
12 Updates the parameters of an existing message template with the
13 values in message_fields.
15 Returns 1 if successful, faults otherwise.
20 message_fields = dict(filter(can_update, Message.fields.items()))
24 Message.fields['message_id'],
28 returns = Parameter(int, '1 if successful')
30 def call(self, auth, message_id, message_fields):
31 message_fields = dict(filter(can_update, message_fields.items()))
33 # Get message information
34 messages = Messages(self.api, [message_id])
36 raise PLCInvalidArgument, "No such message"
39 message.update(message_fields)