Changeset 6749
- Timestamp:
- 13 Sep 2011, 15:46:34 (13 years ago)
- Location:
- main/waeup.sirp/trunk/src/waeup/sirp/students
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.sirp/trunk/src/waeup/sirp/students/student.py
r6704 r6749 19 19 import grok 20 20 from grok import index 21 from zope.component.interfaces import IFactory , ComponentLookupError21 from zope.component.interfaces import IFactory 22 22 from zope.interface import implementedBy 23 23 from hurry.workflow.interfaces import IWorkflowInfo, IWorkflowState … … 40 40 super(Student, self).__init__() 41 41 IWorkflowInfo(self).fireTransition('create') 42 # The catalogdoesn't exist in unit tests42 # The site doesn't exist in unit tests 43 43 try: 44 self.student_id = generate_student_id('?') 45 except ComponentLookupError: 44 students = grok.getSite()['students'] 45 self.student_id = generate_student_id(students,'?') 46 except TypeError: 46 47 self.student_id = u'Z654321' 47 48 self.password = None -
main/waeup.sirp/trunk/src/waeup/sirp/students/utils.py
r6742 r6749 3 3 4 4 from random import SystemRandom as r 5 from waeup.sirp.students.catalog import search6 5 7 def generate_student_id(letter): 8 # XXX: using catalog search here might be overkill? 6 def generate_student_id(students,letter): 9 7 if letter == '?': 10 8 letter= r().choice('ABCDEFGHKLMNPQRSTUVWXY') 11 9 sid = u"%c%d" % (letter,r().randint(99999,1000000)) 12 while s earch(query=sid,searchtype='student_id'):10 while sid in students.keys(): 13 11 sid = u"%c%d" % (letter,r().randint(99999,1000000)) 14 12 return sid
Note: See TracChangeset for help on using the changeset viewer.