Return the user session for a client.

        The only difference with the :func:`socketio.Server.get_session`
        method is that when the ``namespace`` argument is not given the
        namespace associated with the class is used.
353115
def get_session(self, sid, namespace=None):
        
        return self.server.get_session(
            sid, namespace=namespace or self.namespace)
1196832
def session_context(fn):
    
    @functools.wraps(fn)
    def wrap(*args, **kwargs):
        session = args[0].Session()  # obtain from self
        result = fn(*args, session=session, **kwargs)
        session.close()
        return result
    return wrap
393650
def session(self) -> str:
        
        session_jwt = None
        self.user = self.user_model.where_username(self.username)
        if self.user is None:
            return None
        self.user.updated()  # update timestamp on user access
        if self.verify_password(self.user.password):
            session_id = Session.create_session_id()
            data = {
                'session_id': session_id,
                'user_id': self.user.id,
                'user_email': self.user.email,
            }
            token_valid_for = \
                current_app.config['AUTH']['JWT']['TOKENS']['VALID_FOR'] if \
                'VALID_FOR' in \
                current_app.config['AUTH']['JWT']['TOKENS'] else 180
            if current_app.config['AUTH']['JWT']['REFRESH_TOKENS']['ENABLED']:
                refresh_token_valid_for = \
                    current_app \
                    .config['AUTH']['JWT']['REFRESH_TOKENS']['VALID_FOR'] if \
                    'VALID_FOR' in \
                    current_app.config['AUTH']['JWT']['REFRESH_TOKENS'] else \
                    86400
                session_jwt = JWT().create_token_with_refresh_token(
                    data,
                    token_valid_for,
                    refresh_token_valid_for)
            else:
                session_jwt = JWT().create_token(data, token_valid_for)
            Session.create_session(session_id, self.user.id)
            return session_jwt
        return None
222052
def get_session_data(self, request):
        
        user = request.session['%suser' % SESSION_KEY]
        profile = request.session['%sprofile' % SESSION_KEY]
        client = request.session['%sclient' % SESSION_KEY]
        return user, profile, client
739289
def _get_at_from_session(self):
        
        try:
            return self.request.session['oauth_%s_access_token'
                                        % get_token_prefix(
                                            self.request_token_url)]
        except KeyError:
            raise OAuthError(
                _('No access token saved for "%s".')
                % get_token_prefix(self.request_token_url))
355926
def get_session(url):
    
    engine = create_engine(url)
    db_session = scoped_session(sessionmaker(engine))
    Base.metadata.create_all(engine)
    return db_session
202771
def client(*args, loop=None, **kwargs):
    
    return _get_default_session(loop=loop).client(*args, **kwargs)
759792
def _get_session_timeout_seconds(cls, session_server):
        

        if session_server.user_company is not None:
            return session_server.user_company.session_timeout
        elif session_server.user_person is not None:
            return session_server.user_person.session_timeout
        elif session_server.user_api_key is not None:
            return session_server \
                .user_api_key \
                .requested_by_user \
                .get_referenced_object() \
                .session_timeout
        else:
            raise BunqException()
117017
def session(self) -> SessionT:
        ''''''
        session = self._session_class()(
            connection_pool=self._connection_pool,
        )
        self.event_dispatcher.notify(self.ClientEvent.new_session, session)
        return session
622074
def _get_session(team, timeout=None):
    
    global _sessions            # pylint:disable=C0103
    session = _sessions.get(team)
    if session is None:
        auth = _create_auth(team, timeout)
        _sessions[team] = session = _create_session(team, auth)

    assert session is not None

    return session
287285
def get_new_client(self, public=True):
        
        return self._get_client(public=public, cached=False)
639517
def _get_requests_session():
    """"""
    global requests_session
    if requests_session is not None:
        return requests_session
    import requests

    requests_session = requests.Session()
    adapter = requests.adapters.HTTPAdapter(
        max_retries=environments.PIPENV_MAX_RETRIES
    )
    requests_session.mount("https://pypi.org/pypi", adapter)
    return requests_session
1101954
def get(self, request):
        
        try:
            client = request.session[self.get_client().get_session_key()]
            logger.debug("API returned: %s", request.GET)            
            client.complete(dict(request.GET.items()))
            request.session[self.get_client().get_session_key()] = client
            return HttpResponseRedirect(self.get_redirect())
        except KeyError:
            return self.error_to_response(request, {'error': "Session expired."})
        except OAuthError, error:
            return self.error_to_response(request, {'error': error})
        except socket.timeout:
            return self.error_to_response(request, {'error':
                _('Could not connect to service (timed out)')})
178257
def refresh_session(self):
        

        if not self._refresh_token:
            if self._username and self._password:
                return self.login(self._username, self._password)

            return

        return self._authenticate(
            grant_type='refresh_token',
            refresh_token=self._refresh_token,
            client_id=self._client_id,
            client_secret=self._client_secret
        )
795891
def client(self):
        """"""

        if self._client is None:
            self._client = get_session(self.user_agent)
        return self._client
739407
def getSession(self):
        """"""
        if self.session is not None:
            return self.session

        # Get value of cookie header that was sent
        cookie_str = self.headers.get('Cookie')
        if cookie_str:
            cookie_obj = SimpleCookie(cookie_str)
            sid_morsel = cookie_obj.get(self.SESSION_COOKIE_NAME, None)
            if sid_morsel is not None:
                sid = sid_morsel.value
            else:
                sid = None
        else:
            sid = None

        # If a session id was not set, create a new one
        if sid is None:
            sid = randomString(16, '0123456789abcdef')
            session = None
        else:
            session = self.server.sessions.get(sid)

        # If no session exists for this session ID, create one
        if session is None:
            session = self.server.sessions[sid] = {}

        session['id'] = sid
        self.session = session
        return session
805904
def get(self, name, default=None):
        '''
        
        '''

        session = self.__get_session_from_db()

        return session.get(name, default)