git://git.onelab.eu
/
plcapi.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix typo
[plcapi.git]
/
PLC
/
BootStates.py
diff --git
a/PLC/BootStates.py
b/PLC/BootStates.py
index
5384634
..
416ca4d
100644
(file)
--- a/
PLC/BootStates.py
+++ b/
PLC/BootStates.py
@@
-4,7
+4,8
@@
# 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: BootStates.py,v 1.5 2006/10/20 17:43:55 mlhuang Exp $
+# $Id$
+# $URL$
#
from PLC.Faults import *
#
from PLC.Faults import *
@@
-25,31
+26,29
@@
class BootState(Row):
}
def validate_boot_state(self, name):
}
def validate_boot_state(self, name):
- # Make sure name is not blank
+
# Make sure name is not blank
if not len(name):
raise PLCInvalidArgument, "Boot state must be specified"
if not len(name):
raise PLCInvalidArgument, "Boot state must be specified"
-
- # Make sure boot state does not alredy exist
- conflicts = BootStates(self.api, [name])
+
+
# Make sure boot state does not alredy exist
+
conflicts = BootStates(self.api, [name])
if conflicts:
raise PLCInvalidArgument, "Boot state name already in use"
if conflicts:
raise PLCInvalidArgument, "Boot state name already in use"
- return name
+
return name
class BootStates(Table):
"""
Representation of the boot_states table in the database.
"""
class BootStates(Table):
"""
Representation of the boot_states table in the database.
"""
- def __init__(self, api, names = None):
+ def __init__(self, api, boot_states = None):
+ Table.__init__(self, api, BootState)
+
sql = "SELECT %s FROM boot_states" % \
", ".join(BootState.fields)
sql = "SELECT %s FROM boot_states" % \
", ".join(BootState.fields)
-
- if names:
- # Separate the list into integers and strings
- sql += " WHERE boot_state IN (%s)" % ", ".join(api.db.quote(names))
- rows = api.db.selectall(sql)
+ if boot_states:
+ sql += " WHERE boot_state IN (%s)" % ", ".join(map(api.db.quote, boot_states))
- for row in rows:
- self[row['boot_state']] = BootState(api, row)
+ self.selectall(sql)