3 from PLC.Method import Method
4 from PLC.Parameter import Parameter, Mixed
5 from PLC.Auth import Auth
6 from PLC.Sessions import Session, Sessions
7 from PLC.Persons import Person, Persons
9 class AddSession(Method):
11 Creates and returns a new session key for the specified user.
12 (Used for website 'user sudo')
18 Mixed(Person.fields['person_id'],
19 Person.fields['email'])
21 returns = Session.fields['session_id']
24 def call(self, auth, person_id_or_email):
26 persons = Persons(self.api, [person_id_or_email], ['person_id', 'email'])
29 raise PLCInvalidArgument("No such person")
32 session = Session(self.api)
33 session['expires'] = int(time.time()) + (24 * 60 * 60)
34 session.sync(commit = False)
35 session.add_person(person, commit = True)
37 return session['session_id']