Esempio n. 1
0
def get_create_student(name='Anonymous'):
    student = get_student()

    if student:
        return (student, False)
    else:
        return (Student.create(name=name, session_id=random_student_id()), True)
Esempio n. 2
0
def get_student():
    student_id = request.cookies.get('student_id')
    if student_id:
        students = Student.select().where(Student.session_id == student_id)
        for s in students:
            return s
    return None
Esempio n. 3
0
def get_student():
    student_id = request.cookies.get('student_id')
    if student_id:
        students = Student.select().where(Student.session_id == student_id)
        for s in students:
            return s
    return None
Esempio n. 4
0
def get_create_student(name='Anonymous'):
    student = get_student()

    if student:
        return (student, False)
    else:
        return (Student.create(name=name,
                               session_id=random_student_id()), True)
Esempio n. 5
0
def random_student_id():
    while True:
        student_id = "".join([random.choice(string.ascii_letters + string.digits) for n in xrange(32)])

        students = Student.select().where(Student.session_id == student_id)
        for student in students:
            break
        else:
            return student_id
Esempio n. 6
0
def random_student_id():
    while True:
        student_id = "".join([
            random.choice(string.ascii_letters + string.digits)
            for n in xrange(32)
        ])

        students = Student.select().where(Student.session_id == student_id)
        for student in students:
            break
        else:
            return student_id