1 from types import StringTypes
6 from PLC.Faults import *
7 from PLC.Parameter import Parameter, Mixed
8 from PLC.Debug import profile
9 from PLC.Timestamp import Timestamp
10 from PLC.Storage.AlchemyObject import AlchemyObj
12 class SitePerson(AlchemyObj):
14 Representation of a row in the site_person table. To use, optionally
15 instantiate with a dict of values. Update as you would a
16 dict. Commit to the database with sync().To use, instantiate
17 with a dict of values.
20 tablename = 'site_person'
23 'site_id': Parameter(int, "Slice identifier", primary_key=True),
24 'person_id': Parameter(int, "Person identifier", indexed=True),
28 def sync(self, commit = True, validate=True):
32 AlchemyObj.sync(self, commit, validate)
33 AlchemyObj.insert(self, dict(self))
35 def delete(self, commit = True):
37 Delete existing slice.
39 AlchemyObj.delete(self, dict(self))
42 class SitePersons(list):
44 Representation of row(s) from the slices table in the
48 def __init__(self, api, filter = None, columns = None):
50 # the view that we're selecting upon: start with view_slices
52 site_persons = SitePerson().select()
53 elif isinstance(filter, dict):
54 site_persons = SitePerson().select(filter=filter)
56 raise PLCInvalidArgument, "Wrong site_person filter %r"%filter
58 for site_person in site_persons:
59 self.append(site_person)
61 def delete(self, filter={}):
62 site_persons = SitePerson().select(filter)
63 for site_person in site_persons: