Initial checkin of new API implementation
[plcapi.git] / PLC / AddressTypes.py
1 #
2 # Functions for interacting with the address_types table in the database
3 #
4 # Mark Huang <mlhuang@cs.princeton.edu>
5 # Copyright (C) 2006 The Trustees of Princeton University
6 #
7 # $Id$
8 #
9
10 from PLC.Parameter import Parameter
11
12 class AddressTypes(dict):
13     """
14     Representation of the address_types table in the database.
15     """
16
17     fields = {
18         'address_type_id': Parameter(int, "Address type identifier"),
19         'name': Parameter(str, "Address type name"),
20         }
21
22     def __init__(self, api):
23         sql = "SELECT address_type_id, name FROM address_types"
24
25         for row in api.db.selectall(sql):
26             self[row['address_type_id']] = row['name']
27             self[row['name']] = row['address_type_id']