X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=PLC%2FMethods%2FGetSession.py;h=8ae8dd1b631fab4261c165c08f32f0e77f2946ba;hb=6bef7b35eec76ff66332cb20f58eb7703c2116f9;hp=82dccbfd4510d44e034c71a071dbe0e88f188ddd;hpb=97e45f2f1aace5f3f34eaa5170e45e915424fbb8;p=plcapi.git diff --git a/PLC/Methods/GetSession.py b/PLC/Methods/GetSession.py index 82dccbf..8ae8dd1 100644 --- a/PLC/Methods/GetSession.py +++ b/PLC/Methods/GetSession.py @@ -12,19 +12,19 @@ class GetSession(Method): Returns a new session key if a user or node authenticated successfully, faults otherwise. - Default value for 'expires' is 24 hours. Otherwise, the returned + Default value for 'expires' is 24 hours. Otherwise, the returned session 'expires' in the given number of seconds. """ roles = ['admin', 'pi', 'user', 'tech', 'node'] accepts = [Auth(), - Parameter(int,"expires", nullok=True)] + Parameter(int, "expires", nullok=True)] returns = Session.fields['session_id'] def call(self, auth, expires=None): # Authenticated with a session key, just return it - if auth.has_key('session'): + if 'session' in auth: return auth['session'] session = Session(self.api) @@ -36,11 +36,11 @@ class GetSession(Method): else: session['expires'] = int(time.time()) + int(expires) - session.sync(commit = False) + session.sync(commit=False) if isinstance(self.caller, Node): - session.add_node(self.caller, commit = True) + session.add_node(self.caller, commit=True) elif isinstance(self.caller, Person): - session.add_person(self.caller, commit = True) + session.add_person(self.caller, commit=True) return session['session_id']