2 # Thierry Parmentelat - INRIA
4 from PLC.Faults import *
5 from PLC.Method import Method
6 from PLC.Parameter import Parameter, Mixed
7 from PLC.Auth import Auth
9 from PLC.PersonTags import PersonTag, PersonTags
10 from PLC.Persons import Person, Persons
12 class DeletePersonTag(Method):
14 Deletes the specified person setting
16 Admins have full access. Non-admins can change their own tags.
18 Returns 1 if successful, faults otherwise.
21 roles = ['admin', 'pi', 'user']
25 PersonTag.fields['person_tag_id']
28 returns = Parameter(int, '1 if successful')
30 def call(self, auth, person_tag_id):
31 person_tags = PersonTags(self.api, [person_tag_id])
33 raise PLCInvalidArgument, "No such person tag %r"%person_tag_id
34 person_tag = person_tags[0]
36 persons = Persons (self.api, person_tag['person_id'])
38 raise PLCInvalidArgument, "No such person %d"%person_tag['person_id']
41 # check authorizations
42 person.caller_may_write_tag(self.api,self.caller,tag_type)
45 self.object_ids = [person_tag['person_tag_id']]