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 NodeNodeGroup(AlchemyObj):
15 Representation of a row in the node_nodegroup 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 = 'node_nodegroup'
24 'nodegroup_id': Parameter(int, "Nodegroup identifier", primary_key=True),
25 'node_id': Parameter(int, "Node identifier", indexed=True),
30 def sync(self, commit = True, validate=True):
34 AlchemyObj.sync(self, commit, validate)
35 AlchemyObj.insert(self, dict(self))
37 def delete(self, commit = True):
39 Delete existing slice.
41 AlchemyObj.delete(self, dict(self))
44 class NodeNodeGroups(list):
46 Representation of row(s) from the node_nodegroup table in the
50 def __init__(self, api, filter = None, columns = None):
52 # the view that we're selecting upon: start with view_slices
54 node_nodegroups = NodeNodeGroup().select()
55 elif isinstance(filter, dict):
56 node_nodegroups = NodeNodeGroup().select(filter=filter)
58 raise PLCInvalidArgument, "Wrong node_nodegroup filter %r"%filter
60 for node_nodegroup in node_nodegroups:
61 self.append(node_nodegroup)