示例#1
0
def get_todo(todo_id):
    oid = None
    
    try:
        oid = ObjectId(todo_id)
    except:
        return bad_id_response()
    
    todos = get_collection()
    todo = todos.find_one({'_id': oid})
    
    if todo is None:
        return make_json_response({'message': 'no todo with id: ' + todo_id}, 404)
    
    todo['id'] = str(todo['_id'])
    del todo['_id']
    
    return make_json_response(todo)
示例#2
0
文件: server.py 项目: truncs/ufav
def get_location(location_id):
    oid = None
    
    try:
        oid = ObjectId(location_id)
    except:
        return bad_id_response()
    
    locations = get_collection()
    location = locations.find_one({'_id': oid})
    
    if location is None:
        return make_json_response({'message': 'no location with id: ' + location_id}, 404)
    
    location['id'] = str(location['_id'])
    del location['_id']
    
    return make_json_response(location)
示例#3
0
def get_todo(todo_id):
    oid = None

    try:
        oid = ObjectId(todo_id)
    except:
        return bad_id_response()

    todos = get_collection()
    todo = todos.find_one({'_id': oid})

    if todo is None:
        return make_json_response({'message': 'no todo with id: ' + todo_id},
                                  404)

    todo['id'] = str(todo['_id'])
    del todo['_id']

    return make_json_response(todo)
示例#4
0
def get_location(location_id):
    """
    Retrieves a specific location.
    :param location_id: str -- The id of location object which will be updated.
    :return: -- Json response The specified location object.
    """
    oid = None
    try:
        oid = ObjectId(location_id)
    except:
        return bad_id_response()

    locations = get_collection()
    location = locations.find_one({'_id': oid})

    if location is None:
        return make_json_response({'message': 'no location with id: ' + location_id}, 404)

    location['id'] = str(location['_id'])
    del location['_id']

    return make_json_response(location)