--- /dev/null
+#
+# Functions for interacting with the address_types table in the database
+#
+# Mark Huang <mlhuang@cs.princeton.edu>
+# Copyright (C) 2006 The Trustees of Princeton University
+#
+
+from types import StringTypes
+from PLC.Faults import *
+from PLC.Parameter import Parameter
+from PLC.Filter import Filter
+from PLC.Storage.AlchemyObj import AlchemyObj
+from PLC.Table import Row, Table
+
+class AddressAddressType(AlchemyObj):
+ """
+ Representation of a row in the address_types table. To use,
+ instantiate with a dict of values.
+ """
+
+ tablename = 'address_types'
+ join_tables = ['address_address_type']
+ fields = {
+ 'address_id': Parameter(int, "Address identifier"),
+ 'address_type_id': Parameter(int, "Address type identifier"),
+ }
+
+
+ def sync(self, insert=False, validate=True):
+ AlchemyObj.sync(self, insert, validate):
+ AlchemyObj.insert(self, dict(self))
+
+
+ def delete(self, commit=True):
+ AlchemyObj.delete(self, dict(self))
+
+class AddressAddressTypes(list):
+ """
+ Representation of the address_types table in the database.
+ """
+
+ def __init__(self, api, filter = None, columns = None):
+ if not filter:
+ address_types = AddressAddressType().select()
+ elif isinstance(address_type_filter, dict):
+ address_types = AddressAddressType().select(filter=filter)
+ else:
+ raise PLCInvalidArgument, "Wrong address address_type filter %r"filter
+
+ for address_type in address_types:
+ self.append(address_type)