2 # Thierry Parmentelat - INRIA
6 from PLC.Faults import *
7 from PLC.Parameter import Parameter
8 from PLC.Filter import Filter
9 from PLC.Table import Row, Table
10 from PLC.TagTypes import TagType, TagTypes
12 class InterfaceSetting(Row):
14 Representation of a row in the interface_setting.
15 To use, instantiate with a dict of values.
18 table_name = 'interface_setting'
19 primary_key = 'interface_setting_id'
21 'interface_setting_id': Parameter(int, "Interface setting identifier"),
22 'interface_id': Parameter(int, "Interface identifier"),
23 'tag_type_id': TagType.fields['tag_type_id'],
24 'tagname': TagType.fields['tagname'],
25 'description': TagType.fields['description'],
26 'category': TagType.fields['category'],
27 'min_role_id': TagType.fields['min_role_id'],
28 'value': Parameter(str, "Interface setting value"),
33 class InterfaceSettings(Table):
35 Representation of row(s) from the interface_setting table in the
39 def __init__(self, api, interface_setting_filter = None, columns = None):
40 Table.__init__(self, api, InterfaceSetting, columns)
42 sql = "SELECT %s FROM view_interface_settings WHERE True" % \
43 ", ".join(self.columns)
45 if interface_setting_filter is not None:
46 if isinstance(interface_setting_filter, (list, tuple, set)):
47 interface_setting_filter = Filter(InterfaceSetting.fields, {'interface_setting_id': interface_setting_filter})
48 elif isinstance(interface_setting_filter, dict):
49 interface_setting_filter = Filter(InterfaceSetting.fields, interface_setting_filter)
50 elif isinstance(interface_setting_filter, int):
51 interface_setting_filter = Filter(InterfaceSetting.fields, {'interface_setting_id': [interface_setting_filter]})
53 raise PLCInvalidArgument, "Wrong interface setting filter %r"%interface_setting_filter
54 sql += " AND (%s) %s" % interface_setting_filter.sql(api)