3 from PLC.Faults import *
4 from PLC.Method import Method
5 from PLC.Parameter import Parameter, Mixed
6 from PLC.Messages import Message, Messages
7 from PLC.Auth import Auth
9 can_update = lambda (field, value): field in \
10 ['template', 'enabled']
12 class UpdateMessage(Method):
14 Updates the parameters of an existing message template with the
15 values in message_fields.
17 Returns 1 if successful, faults otherwise.
22 message_fields = dict(filter(can_update, Message.fields.items()))
26 Message.fields['message_id'],
30 returns = Parameter(int, '1 if successful')
32 def call(self, auth, message_id, message_fields):
33 message_fields = dict(filter(can_update, message_fields.items()))
35 # Get message information
36 messages = Messages(self.api, [message_id])
38 raise PLCInvalidArgument, "No such message"
41 message.update(message_fields)
43 self.event_objects = {'Message': [message['message_id']]}