Ejemplo n.º 1
0
def edit_post(student_id):
    student = load_object(student_id)

    forms = request.forms
    sid = forms.get("id")
    name = forms.get("name")

    student.name = name
    keys = forms.keys()
    response.status = 303
    for k in keys:
        if k.startswith("grades_"):
            v = forms.get(k)
            vl = v.strip().split(',')
            try:
                vl = [int(g) for g in vl]
            except ValueError:
                response.set_header(
                    'Location',
                    '/edit/' + student_id + "?message=Error+in+a+grade+list.")
                return {}
            grade_name = k.replace("grades_", "")
            student.replace_grades(grade_name, vl)
    new_id = subscribers([student], IStoreEvent)[0].store()
    response.set_header('Location',
                        '/edit/' + new_id + "?message=Student+updated.")
    return {}  # Enter the body here
Ejemplo n.º 2
0
def edit_get(student_id):
    #storage=getUtility(IStorage, name="database")
    #student=storage.get(student_id, Student)
    student = load_object(student_id)
    message = request.query.get("message", None)
    return {
        "id": student_id,
        "name": student.name,
        "grades": student.grades,
        "request": request,
        "message": message
    }
Ejemplo n.º 3
0
def edit_post(student_id):
    student = load_object(student_id)

    forms = request.forms
    sid = forms.get("id")
    name = forms.get("name")

    student.name = name
    keys = forms.keys()
    response.status = 303
    for k in keys:
        if k.startswith("grades_"):
            v = forms.get(k)
            vl = v.strip().split(",")
            try:
                vl = [int(g) for g in vl]
            except ValueError:
                response.set_header("Location", "/edit/" + student_id + "?message=Error+in+a+grade+list.")
                return {}
            grade_name = k.replace("grades_", "")
            student.replace_grades(grade_name, vl)
    new_id = subscribers([student], IStoreEvent)[0].store()
    response.set_header("Location", "/edit/" + new_id + "?message=Student+updated.")
    return {}  # Enter the body here
Ejemplo n.º 4
0
def remote():
    group=load_object("http://127.0.0.1:8080/5",Group,RemoteKey)
    edit(group)
Ejemplo n.º 5
0
def real():
    group=load_object(5, Group)
    edit(group)
Ejemplo n.º 6
0
def get_student(id):
    return load_object(id)
Ejemplo n.º 7
0
def edit_get(student_id):
    # storage=getUtility(IStorage, name="database")
    # student=storage.get(student_id, Student)
    student = load_object(student_id)
    message = request.query.get("message", None)
    return {"id": student_id, "name": student.name, "grades": student.grades, "request": request, "message": message}