From dcaef11385510ec5441ec4870ba4b172365adbf2 Mon Sep 17 00:00:00 2001 From: Mark Huang Date: Mon, 6 Nov 2006 20:48:33 +0000 Subject: [PATCH] - allow enabled to be specified as a filter --- PLC/ConfFiles.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) 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) -- 2.47.0