X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=PLC%2FNetworkMethods.py;h=a3d306b8afe5ed7668da7fd996d602817616e69c;hb=d959fffe2878262ba0525225f2241b7c6004b3ea;hp=0dbbe43d5defd7b4b08780f92afa612bed15123e;hpb=5dc283f954f5a2b82429aa0c5d5d8c5fc64eefac;p=plcapi.git diff --git a/PLC/NetworkMethods.py b/PLC/NetworkMethods.py index 0dbbe43..a3d306b 100644 --- a/PLC/NetworkMethods.py +++ b/PLC/NetworkMethods.py @@ -4,7 +4,7 @@ # Mark Huang # Copyright (C) 2006 The Trustees of Princeton University # -# $Id: NetworkMethods.py,v 1.1 2006/10/10 20:23:49 mlhuang Exp $ +# $Id: NetworkMethods.py,v 1.3 2006/10/24 20:02:22 mlhuang Exp $ # from PLC.Faults import * @@ -25,11 +25,8 @@ class NetworkMethod(Row): } def validate_method(self, name): - # Remove leading and trailing spaces - name = name.strip() - - # Make sure name is not blank after we removed the spaces - if not name: + # Make sure name is not blank + if not len(name): raise PLCInvalidArgument, "Network method must be specified" # Make sure network method does not alredy exist @@ -44,15 +41,13 @@ class NetworkMethods(Table): Representation of the network_methods table in the database. """ - def __init__(self, api, names = None): + def __init__(self, api, methods = None): + Table.__init__(self, api, NetworkMethod) + sql = "SELECT %s FROM network_methods" % \ ", ".join(NetworkMethod.fields) - if names: - # Separate the list into integers and strings - sql += " WHERE method IN (%s)" % ", ".join(api.db.quote(names)) - - rows = api.db.selectall(sql) + if methods: + sql += " WHERE method IN (%s)" % ", ".join(map(api.db.quote, methods)) - for row in rows: - self[row['method']] = NetworkMethod(api, row) + self.selectall(sql)