def get_auth_or_create_guest(request): auth_json = request.session.get(SESSION_AUTH, None) if auth_json is None: auth = Instance.get_auth('guest', '') if auth is not None: request.session[SESSION_AUTH] = serialize_auth(auth) else: auth = deserialize_auth(auth_json) return auth
def end_request(request, auth): request.session[SESSION_AUTH] = serialize_auth(auth)