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 SlicePerson(AlchemyObj):
15 Representation of a row in the slice_person 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 = 'slice_person'
24 'slice_id': Parameter(int, "Slice identifier", primary_key=True),
25 'person_id': Parameter(int, "Person identifier", indexed=True),
29 def sync(self, commit = True, validate=True):
33 AlchemyObj.sync(self, commit, validate)
34 AlchemyObj.insert(self, dict(self))
36 def delete(self, commit = True):
38 Delete existing slice.
40 AlchemyObj.delete(self, dict(self))
43 class SlicePersons(list):
45 Representation of row(s) from the slices table in the
49 def __init__(self, api, filter = None, columns = None):
51 # the view that we're selecting upon: start with view_slices
53 slice_persons = SlicePerson().select()
54 elif isinstance(filter, dict):
55 slice_persons = SlicePerson().select(filter=filter)
57 raise PLCInvalidArgument, "Wrong slice_person filter %r"%filter
59 for slice_person in slice_persons:
60 self.append(slice_person)