1 from types import StringTypes
6 from PLC.Faults import *
7 from PLC.Parameter import Parameter, Mixed
8 from PLC.Filter import Filter
9 from PLC.Debug import profile
10 from PLC.Timestamp import Timestamp
11 from PLC.Storage.AlchemyObject import AlchemyObj
13 class PCUNodePort(AlchemyObj):
15 Representation of a row in the pcu_node_ports table. To use, optionally
16 instantiate with a dict of values. Update as you would a
17 dict. Commit to the database with sync().To use, instantiate
18 with a dict of values.
21 tablename = 'pcu_node_port'
24 'pcu_id': Parameter(int, "PCU identifier", primary_key=True),
25 'node_id': Parameter(int, "Node identifier", primary_key=True),
26 'port': Parameter(int, "port", indexed=True),
31 def sync(self, commit = True, validate=True):
35 AlchemyObj.sync(self, commit, validate)
36 AlchemyObj.insert(self, dict(self))
38 def delete(self, commit = True):
40 Delete existing slice.
42 AlchemyObj.delete(self, dict(self))
45 class PCUNodePorts(list):
47 Representation of row(s) from the pcu_node_port table in the
51 def __init__(self, api, filter = None, columns = None):
53 # the view that we're selecting upon: start with view_slices
55 pcu_node_ports = PCUNodePort().select()
56 elif isinstance(filter, dict):
57 pcu_node_ports = PCUNodePort().select(filter=filter)
59 raise PLCInvalidArgument, "Wrong pcu_node_port filter %r"%filter
61 for pcu_node_port in pcu_node_ports:
62 self.append(PCUNodePort(api, object=pcu_node_port))