Changeset 6662 for main


Ignore:
Timestamp:
3 Sep 2011, 02:27:24 (13 years ago)
Author:
uli
Message:
  • Use stronger randomization.
  • Make student ids unicode (required when used in interfaces).
File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.sirp/trunk/src/waeup/sirp/students/utils.py

    r6651 r6662  
    22"""
    33
    4 import random
     4from random import SystemRandom as r
    55from waeup.sirp.students.catalog import search
    66
    77def generate_student_id(letter):
    8     r = random
     8    # XXX: using catalog search here might be overkill?
    99    if letter == '?':
    1010        letter= r.choice('ABCDEFGHKLMNPQRSTUVWXY')
    11     sid = "%c%d" % (letter,r.randint(99999,1000000))
     11    sid = u"%c%d" % (letter,r.randint(99999,1000000))
    1212    while search(query=sid,searchtype='student_id'):
    13         sid = "%c%d" % (letter,r.randint(99999,1000000))
     13        sid = u"%c%d" % (letter,r.randint(99999,1000000))
    1414    return sid
Note: See TracChangeset for help on using the changeset viewer.