2 # Thierry Parmentelat - INRIA
4 from PLC.Faults import *
5 from PLC.Parameter import Parameter
6 from PLC.Filter import Filter
7 from PLC.Table import Row, Table
8 from PLC.TagTypes import TagType, TagTypes
9 from PLC.Persons import Person
13 Representation of a row in the person_tag.
14 To use, instantiate with a dict of values.
17 table_name = 'person_tag'
18 primary_key = 'person_tag_id'
20 'person_tag_id': Parameter(int, "Person setting identifier"),
21 'person_id': Person.fields['person_id'],
22 'email': Person.fields['email'],
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 'value': Parameter(str, "Person setting value"),
32 class PersonTags(Table):
34 Representation of row(s) from the person_tag table in the
38 def __init__(self, api, person_tag_filter = None, columns = None):
39 Table.__init__(self, api, PersonTag, columns)
41 sql = "SELECT %s FROM view_person_tags WHERE True" % \
42 ", ".join(self.columns)
44 if person_tag_filter is not None:
45 if isinstance(person_tag_filter, (list, tuple, set, int, long)):
46 person_tag_filter = Filter(PersonTag.fields, {'person_tag_id': person_tag_filter})
47 elif isinstance(person_tag_filter, dict):
48 person_tag_filter = Filter(PersonTag.fields, person_tag_filter)
50 raise PLCInvalidArgument, "Wrong person setting filter %r"%person_tag_filter
51 sql += " AND (%s) %s" % person_tag_filter.sql(api)