git://git.onelab.eu
/
plcapi.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
3876b7e
)
- allow enabled to be specified as a filter
author
Mark Huang
<mlhuang@cs.princeton.edu>
Mon, 6 Nov 2006 20:48:33 +0000
(20:48 +0000)
committer
Mark Huang
<mlhuang@cs.princeton.edu>
Mon, 6 Nov 2006 20:48:33 +0000
(20:48 +0000)
PLC/ConfFiles.py
patch
|
blob
|
history
diff --git
a/PLC/ConfFiles.py
b/PLC/ConfFiles.py
index
a80c96a
..
ef0e301
100644
(file)
--- a/
PLC/ConfFiles.py
+++ b/
PLC/ConfFiles.py
@@
-4,7
+4,7
@@
# Mark Huang <mlhuang@cs.princeton.edu>
# Copyright (C) 2006 The Trustees of Princeton University
#
# Mark Huang <mlhuang@cs.princeton.edu>
# 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 *
#
from PLC.Faults import *
@@
-138,15
+138,18
@@
class ConfFiles(Table):
Representation of the conf_files table in the database.
"""
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
", ".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)
for row in rows:
self[row['conf_file_id']] = ConfFile(api, row)