Changeset 429


Ignore:
Timestamp:
26 Aug 2006, 14:06:48 (18 years ago)
Author:
joachim
Message:

check for duplicate student_id

File:
1 edited

Legend:

Unmodified
Added
Removed
  • WAeUP_SRP/trunk/Students.py

    r427 r429  
    44from AccessControl import ClassSecurityInfo
    55from AccessControl.SecurityManagement import newSecurityManager
    6 
     6from zExceptions import BadRequest
    77from Products.CMFCore.utils import UniqueObject, getToolByName
    88from Products.CMFCore.permissions import View
     
    2525    r = random
    2626    return "%c%d" % (r.choice('ABCDEFGHKLMNPQRSTUVWXY'),r.randint(99999,1000000))
    27 
    28 
    2927
    3028class StudentsFolder(CPSDocument): ###(
     
    9593                #self.log('Creating Faculty %(id)s = %(Title)s' % faculty)
    9694                logger.info('%(tr_count)s: Creating Student with ID %(sid)s Matric_no %(matric_no)s ' % vars())
    97                 students_folder.invokeFactory('Student', sid)
     95                not_created = True
     96                while not_created:
     97                    try:
     98                        students_folder.invokeFactory('Student', sid)
     99                        not_created = False
     100                    except BadRequest:
     101                        sid = generateStudentId()
     102                logger.info('%(tr_count)s: Creating Student with ID %(sid)s Matric_no %(matric_no)s ' % vars())
    98103                s = getattr(self,sid)
    99104                s.invokeFactory('StudentPersonal','personal')
Note: See TracChangeset for help on using the changeset viewer.