"""General helper functions for the student section. """ from random import SystemRandom as r from waeup.sirp.students.catalog import search def generate_student_id(letter): # XXX: using catalog search here might be overkill? if letter == '?': letter= r().choice('ABCDEFGHKLMNPQRSTUVWXY') sid = u"%c%d" % (letter,r().randint(99999,1000000)) while search(query=sid,searchtype='student_id'): sid = u"%c%d" % (letter,r().randint(99999,1000000)) return sid