2 # Functions for interacting with the node_types table in the database
7 from PLC.Faults import *
8 from PLC.Parameter import Parameter
9 from PLC.Table import Row, Table
13 Representation of a row in the node_types table. To use,
14 instantiate with a dict of values.
17 table_name = 'node_types'
18 primary_key = 'node_type'
19 join_tables = ['nodes']
21 'node_type': Parameter(str, "Node type", max = 20),
24 def validate_node_type(self, name):
25 # Make sure name is not blank
27 raise PLCInvalidArgument, "Node type must be specified"
29 # Make sure node type does not alredy exist
30 conflicts = NodeTypes(self.api, [name])
32 raise PLCInvalidArgument, "Node type name already in use"
36 class NodeTypes(Table):
38 Representation of the node_types table in the database.
41 def __init__(self, api, node_types = None):
42 Table.__init__(self, api, NodeType)
44 sql = "SELECT %s FROM node_types" % \
45 ", ".join(NodeType.fields)
48 sql += " WHERE node_type IN (%s)" % ", ".join(map(api.db.quote, node_types))