From: Mark Huang Date: Mon, 6 Nov 2006 20:48:33 +0000 (+0000) Subject: - allow enabled to be specified as a filter X-Git-Tag: pycurl-7_13_1~378 X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;h=dcaef11385510ec5441ec4870ba4b172365adbf2;p=plcapi.git - allow enabled to be specified as a filter --- diff --git a/PLC/ConfFiles.py b/PLC/ConfFiles.py index a80c96a3..ef0e3013 100644 --- a/PLC/ConfFiles.py +++ b/PLC/ConfFiles.py @@ -4,7 +4,7 @@ # Mark Huang # Copyright (C) 2006 The Trustees of Princeton University # -# $Id: ConfFiles.py,v 1.5 2006/10/25 14:29:13 mlhuang Exp $ +# $Id: ConfFiles.py,v 1.6 2006/11/02 18:32:55 mlhuang Exp $ # from PLC.Faults import * @@ -138,15 +138,18 @@ class ConfFiles(Table): Representation of the conf_files table in the database. """ - def __init__(self, api, conf_file_ids = None): - sql = "SELECT %s FROM view_conf_files" % \ + def __init__(self, api, conf_file_ids = None, enabled = None): + sql = "SELECT %s FROM view_conf_files WHERE True" % \ ", ".join(ConfFile.fields) if conf_file_ids: # Separate the list into integers and strings - sql += " WHERE conf_file_id IN (%s)" % ", ".join(map(str, api.db.quote(conf_file_ids))) + sql += " AND conf_file_id IN (%s)" % ", ".join(map(str, api.db.quote(conf_file_ids))) - rows = api.db.selectall(sql) + if enabled is not None: + sql += " AND enabled = %(enabled)s" + + rows = api.db.selectall(sql, locals()) for row in rows: self[row['conf_file_id']] = ConfFile(api, row)