zeeguu/api/api/utils/route_wrappers.py
def with_session(view):
    """
    Decorator checks that user is in a session.

    Every API endpoint annotated with @with_session
     expects a session object to be passed as a GET parameter

    Example: API_URL/learned_language?session=123141516
    """

    @functools.wraps(view)
    def wrapped_view(*args, **kwargs):
        try:
            session_id = int(flask.request.args["session"])
        except:
            flask.abort(401)
        session = Session.query.get(session_id)
        if session is None:
            flask.abort(401)
        flask.g.user = session.user
        session.update_use_date()

        zeeguu.core.log(str(flask.g.user.id) + " API CALL: " + str(view))

        zeeguu.core.db.session.add(session)
        # TODO: remove this commit? and add it after such that the session can be added with the next commit?
        zeeguu.core.db.session.commit()
        return view(*args, **kwargs)

        zeeguu.core.db.session.close()

    return wrapped_view

    Decorator checks that user is in a session.

    Every API endpoint annotated with @with_session
     expects a session object to be passed as a GET parameter

    Example: API_URL/learned_language?session=123141516
    
Decorator checks that user is in a session.
Every API endpoint annotated with @with_session
expects a session object to be passed as a GET parameter


Decorator checks that user is in a session . Every API endpoint annotated with @with_session expects a session object to be passed as a GET parameter
def with_session(view):
    @functools.wraps(view)
    def wrapped_view(*args, **kwargs):
        try:
            session_id = int(flask.request.args["session"])
        except:
            flask.abort(401)
        session = Session.query.get(session_id)
        if session is None:
            flask.abort(401)
        flask.g.user = session.user
        session.update_use_date()
        zeeguu.core.log(str(flask.g.user.id) + " API CALL: " + str(view))
        zeeguu.core.db.session.add(session)
        zeeguu.core.db.session.commit()
        return view(*args, **kwargs)
        zeeguu.core.db.session.close()
    return wrapped_view
def with_session ( view ) : @ functools . wraps ( view ) def wrapped_view ( * args , ** kwargs ) : try : session_id = int ( flask . request . args [ "session" ] ) except : flask . abort ( 401 ) session = Session . query . get ( session_id ) if session is None : flask . abort ( 401 ) flask . g . user = session . user session . update_use_date ( ) zeeguu . core . log ( str ( flask . g . user . id ) + " API CALL: " + str ( view ) ) zeeguu . core . db . session . add ( session ) zeeguu . core . db . session . commit ( ) return view ( * args , ** kwargs ) zeeguu . core . db . session . close ( ) return wrapped_view
Decorator checks that user is in a session.
Decorator checks that user is in a session .
"""
    Decorator checks that user is in a session.

    Every API endpoint annotated with @with_session
     expects a session object to be passed as a GET parameter

    Example: API_URL/learned_language?session=123141516
    """ # TODO: remove this commit? and add it after such that the session can be added with the next commit?
view