2 # Functions for interacting with the node_types table in the database
8 from PLC.Faults import *
9 from PLC.Parameter import Parameter
10 from PLC.Table import Row, Table
14 Representation of a row in the node_types table. To use,
15 instantiate with a dict of values.
18 table_name = 'node_types'
19 primary_key = 'node_type'
20 join_tables = ['nodes']
22 'node_type': Parameter(str, "Node type", max = 20),
25 def validate_node_type(self, name):
26 # Make sure name is not blank
28 raise PLCInvalidArgument, "Node type must be specified"
30 # Make sure node type does not alredy exist
31 conflicts = NodeTypes(self.api, [name])
33 raise PLCInvalidArgument, "Node type name already in use"
37 class NodeTypes(Table):
39 Representation of the node_types table in the database.
42 def __init__(self, api, node_types = None):
43 Table.__init__(self, api, NodeType)
45 sql = "SELECT %s FROM node_types" % \
46 ", ".join(NodeType.fields)
49 sql += " WHERE node_type IN (%s)" % ", ".join(map(api.db.quote, node_types))