2 # Functions for interacting with the node_types table in the database
6 from PLC.Faults import *
7 from PLC.Parameter import Parameter
8 from PLC.Table import Row, Table
12 Representation of a row in the node_types table. To use,
13 instantiate with a dict of values.
16 table_name = 'node_types'
17 primary_key = 'node_type'
18 join_tables = ['nodes']
20 'node_type': Parameter(str, "Node type", max = 20),
23 def validate_node_type(self, name):
24 # Make sure name is not blank
26 raise PLCInvalidArgument("Node type must be specified")
28 # Make sure node type does not alredy exist
29 conflicts = NodeTypes(self.api, [name])
31 raise PLCInvalidArgument("Node type name already in use")
35 class NodeTypes(Table):
37 Representation of the node_types table in the database.
40 def __init__(self, api, node_types = None):
41 Table.__init__(self, api, NodeType)
43 sql = "SELECT %s FROM node_types" % \
44 ", ".join(NodeType.fields)
47 sql += " WHERE node_type IN (%s)" % ", ".join( [ api.db.quote (t) for t in node_types ] )