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.3 2006/11/10 17:06:35 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 'subject': Parameter(str, "Message summary", nullok = True),
23 'template': Parameter(str, "Message template", nullok = True),
24 'enabled': Parameter(bool, "Message is enabled"),
27 class Messages(Table):
29 Representation of row(s) from the messages table in the database.
32 def __init__(self, api, message_ids, enabled = None):
33 Table.__init__(self, api, Message)
35 sql = "SELECT %s from messages WHERE True" % \
36 ", ".join(Message.fields)
39 sql += " AND message_id IN (%s)" % ", ".join(map(api.db.quote, message_ids))
41 if enabled is not None:
42 sql += " AND enabled IS %s" % enabled