4 from PLC.Method import Method
5 from PLC.Parameter import Parameter, Mixed
6 from PLC.Auth import Auth
7 from PLC.Sessions import Session, Sessions
8 from PLC.Persons import Person, Persons
10 class AddSession(Method):
12 Creates and returns a new session key for the specified user.
13 (Used for website 'user sudo')
19 Mixed(Person.fields['person_id'],
20 Person.fields['email'])
22 returns = Session.fields['session_id']
25 def call(self, auth, person_id_or_email):
27 persons = Persons(self.api, [person_id_or_email], ['person_id', 'email'])
30 raise PLCInvalidArgument, "No such person"
33 session = Session(self.api)
34 session['expires'] = int(time.time()) + (24 * 60 * 60)
35 session.sync(commit = False)
36 session.add_person(person, commit = True)
38 return session['session_id']