Esempio n. 1
0
def create_user(request, uri, headers):
    try:
        fullname = request.parsed_body['fullname'][0]
        user = User(fullname=fullname)
        save(user)
        session.refresh(user)
        resp = json.dumps({'data': user.as_dict()})

        return 200, headers, resp
    except:
        return 400, headers, 'ERROR in create_user.'
Esempio n. 2
0
def create_user(request, uri, headers):
    try:
        fullname = request.parsed_body['fullname'][0]
        user = User(fullname=fullname)
        save(user)
        session.refresh(user)
        resp = json.dumps(
            {
                'data': user.as_dict()
            }
        )

        return 200, headers, resp
    except:
        return 400, headers, 'ERROR in create_user.'
Esempio n. 3
0
def create_node(request, uri, headers):
    try:
        user_id = user_id_from_request(request)
        user = session.query(User).filter(User.id == user_id).one()
        title = request.parsed_body['title'][0]
        node = Node(user=user, title=title)
        save(node)
        session.refresh(node)
        provider = File(type=File.FOLDER, user=user, node=node)
        node.files.append(provider)
        save(node)
        session.refresh(node)
        resp = json.dumps({'data': node.as_dict()})
        return (200, headers, resp)
    except:
        return (400, headers, 'cant get user nodes')
Esempio n. 4
0
def create_node(request, uri, headers):
    try:
        user_id = user_id_from_request(request)
        user = session.query(User).filter(User.id ==user_id).one()
        title = request.parsed_body['title'][0]
        node = Node(user=user, title=title)
        save(node)
        session.refresh(node)
        provider = File(type=File.FOLDER, user=user, node=node)
        node.files.append(provider)
        save(node)
        session.refresh(node)
        resp = json.dumps({
            'data':node.as_dict()
        })
        return (200, headers, resp)
    except:
        return (400, headers, 'cant get user nodes')