2 # Functions for interacting with the messages table in the database
4 # Tony Mack <tmack@cs.princeton.edu>
5 # Copyright (C) 2006 The Trustees of Princeton University
7 # $Id: Messages.py,v 1.4 2006/10/31 21:46:14 mlhuang Exp $
10 from PLC.Parameter import Parameter
11 from PLC.Table import Row, Table
15 Representation of a row in the messages table.
18 table_name = 'messages'
19 primary_key = 'message_id'
21 'message_id': Parameter(str, "Message identifier"),
22 'template': Parameter(str, "Message template", nullok = True),
23 'enabled': Parameter(bool, "Message is enabled"),
26 class Messages(Table):
28 Representation of row(s) from the messages table in the database.
31 def __init__(self, api, message_ids, enabled = None):
34 sql = "SELECT %s from messages" % ", ".join(Message.fields)
36 if enabled is not None:
37 sql += " WHERE enabled IS %(enabled)s"
39 rows = self.api.db.selectall(sql, locals())
42 self[row['message_id']] = Message(api, row)