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 SiteAddress(AlchemyObj):
14 Representation of a row in the site_address 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_address'
23 'site_id': Parameter(int, "Slice identifier", primary_key=True),
24 'address_id': Parameter(int, "Address 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 SiteAddresses(list):
44 Representation of row(s) from the site address 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_addresses = SiteAddress().select()
53 elif isinstance(filter, dict):
54 site_addresses = SiteAddress().select(filter=filter)
56 raise PLCInvalidArgument, "Wrong site_address filter %r"%filter
58 for site_address in site_address:
59 site_address = SiteAddress(self.api, object=site_address)
60 self.append(site_address)