コード例 #1
0
ファイル: views.py プロジェクト: ishanm/rhaptos2.repo
def workspaceGET():
    ''' '''
    # TODO - should whoami redirect to a login page?
    ### yes the client should only expect to handle HTTP CODES
    ### compare on userID

    identity = auth.whoami()
    if not identity:
        abort(403)
    else:
        wout = {}
        dolog("INFO", "Calling workspace with %s" % identity.userID)
        w = model.workspace_by_user(identity.userID)
        dolog("INFO", repr(w))
        ## w is a list of models (folders, cols etc).
        # it would require some flattening or a JSONEncoder but we just want
        # short form for now
        short_format_list = [{
            "id": i.id_, "title": i.title, "mediaType": i.mediaType} for i in w]
        flatten = json.dumps(short_format_list)

    resp = flask.make_response(flatten)
    resp.content_type = 'application/json; charset=utf-8'
    resp.headers["Access-Control-Allow-Origin"] = "*"

    auth.callstatsd('rhaptos2.e2repo.workspace.GET')
    return resp
コード例 #2
0
ファイル: views.py プロジェクト: ighostxhub/rhaptos2.repo
def whoamiGET():
    '''
    returns
    Either 401 if OpenID not available or JSON document of form

    {"openid_url": "https://www.google.com/accounts/o8/id?id=AItOawlWRa8JTK7NyaAvAC4KrGaZik80gsKfe2U",  # noqa
     "email": "Not Implemented",
     "name": "Not Implemented"}


    '''
    ### todo: return 401 code and let ajax client put up login.
    userd = auth.whoami()  # same as g.user_details

    if userd:
        jsond = json.dumps(userd)
        resp = apply_cors(jsond)
        return resp
    else:
        return("Not logged in", 401)  # FIXME - zombie code again
コード例 #3
0
ファイル: views.py プロジェクト: ighostxhub/rhaptos2.repo
def workspaceGET():
    ''' '''
    # TODO - should whoami redirect to a login page?
    ### yes the client should only expect to handle HTTP CODES
    ### compare on userID

    userd = auth.whoami()
    if not userd:
        abort(403)
    else:
        wout = {}
        lgr.info("Calling workspace with %s" % userd['user_id'])
        w = model.workspace_by_user(userd['user_id'])
        lgr.info(repr(w))
        ## w is a list of models (folders, cols etc).
        # it would require some flattening or a JSONEncoder but we just want
        # short form for now
        short_format_list = [{
            "id": i.id_, "title": i.title, "mediaType": i.mediaType} for i in w]
        flatten = json.dumps(short_format_list)
    resp = apply_cors(flatten)
    return resp
コード例 #4
0
ファイル: views.py プロジェクト: dak/rhaptos2.repo
def before_request():
    g.user = auth.whoami()
コード例 #5
0
ファイル: views.py プロジェクト: ishanm/rhaptos2.repo
def requestid():
    g.requestid = uuid.uuid4()
    g.request_id = g.requestid
    g.user = auth.whoami()