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
bugfix for when trying to quote enumerate types
[plcapi.git]
/
PLC
/
NetworkTypes.py
diff --git
a/PLC/NetworkTypes.py
b/PLC/NetworkTypes.py
index
a3416c8
..
2b5ff4d
100644
(file)
--- a/
PLC/NetworkTypes.py
+++ b/
PLC/NetworkTypes.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: NetworkTypes.py,v 1.2 2006/10/20 17:47:34 mlhuang Exp $
+# $Id$
+# $URL$
#
from PLC.Faults import *
#
from PLC.Faults import *
@@
-19,7
+20,7
@@
class NetworkType(Row):
table_name = 'network_types'
primary_key = 'type'
table_name = 'network_types'
primary_key = 'type'
- join_tables = ['
nodenetwork
s']
+ join_tables = ['
interface
s']
fields = {
'type': Parameter(str, "Network type", max = 20),
}
fields = {
'type': Parameter(str, "Network type", max = 20),
}
@@
-41,15
+42,13
@@
class NetworkTypes(Table):
Representation of the network_types table in the database.
"""
Representation of the network_types table in the database.
"""
- def __init__(self, api, names = None):
+ def __init__(self, api, types = None):
+ Table.__init__(self, api, NetworkType)
+
sql = "SELECT %s FROM network_types" % \
", ".join(NetworkType.fields)
sql = "SELECT %s FROM network_types" % \
", ".join(NetworkType.fields)
- if names:
- # Separate the list into integers and strings
- sql += " WHERE type IN (%s)" % ", ".join(api.db.quote(names))
-
- rows = api.db.selectall(sql)
+ if types:
+ sql += " WHERE type IN (%s)" % ", ".join(map(api.db.quote, types))
- for row in rows:
- self[row['type']] = NetworkType(api, row)
+ self.selectall(sql)