Index: WAeUP_SRP/trunk/Students.py
===================================================================
--- WAeUP_SRP/trunk/Students.py	(revision 1706)
+++ WAeUP_SRP/trunk/Students.py	(revision 1707)
@@ -428,6 +428,6 @@
             app = student.application
             app_doc = app.getContent()
-            picture ="%s/import/pictures/%s.jpg" % (i_home,jamb_reg_no)
             #import pdb;pdb.set_trace()
+            picture ="%s/import/pictures/%s.jpg" % (i_home,picture_id)
             if os.path.exists(picture):
                 file = open(picture)
@@ -538,7 +538,7 @@
     ###)
 
-    security.declareProtected(ModifyPortalContent,"createNewStudents")###(
-    def createParttimeStudents(self):
-        """load Parttime Studentdata from CSV values"""
+    security.declareProtected(ModifyPortalContent,"createStudents")###(
+    def createStudents(self):
+        """load Studentdata from CSV values"""
         import transaction
         import random
@@ -546,20 +546,15 @@
         wftool = self.portal_workflow
         students_folder = self.portal_catalog({'meta_type': 'StudentsFolder'})[-1].getObject()
-        csv_d = {'jamb_reg_no': "Reg_No",
-                 'jamb_firstname': "Firstname",
-                 'jamb_middlename': "Middlename",
-                 'jamb_lastname': "Lastname",
-                 'jamb_sex': "Sex",
-                 'entry_mode': 'Entry_mode',
-                 'jamb_age': "Age",
-                 'jamb_state': "State",
-##                 'jamb_first_cos': "AdminCourse",
-                 'faculty': "AdminFaculty",
-                 'course_code': "AdmitCoscode",
-                 'stud_status':"AdmitStatus",
-                 'department': "AdmitDept",
-                 'jamb_lga': "LGA",
+        csv_d = {'jamb_reg_no': "reg_no",
+                 'entry_mode': 'entry_mode',
+                 'jamb_firstname': "firstname",
+                 'jamb_middlename': "middlename",
+                 'jamb_lastname': "lastname",
+                 'jamb_sex': "sex",
+                 'jamb_state': "state",
+                 'birthday': "date_of_birth",
                  'app_email': "email",
-                 'app_mobile': "PhoneNumbers",
+                 'study_course': "study_course",
+                 'perm_address': "address",
                  }
         csv_fields = [f[1] for f in csv_d.items()]
@@ -576,55 +571,42 @@
         logger = logging.getLogger('Students.StudentsFolder.createNewStudents')
         logger.info('Start loading from %s.csv' % name)
-        l = self.portal_catalog({'meta_type': "Certificate"})
         certs = {}
-        cert_docs = {}
-        for f in l:
-            certs[f.getId] = f.getObject().getContent()
         try:
-            result = csv.DictReader(open("%s/import/%s.csv" % (i_home,name),"rb"))
+            results = csv.DictReader(open("%s/import/%s.csv" % (i_home,name),"rb"))
         except:
             logger.error('Error reading %s.csv' % name)
             return
-        for jamb in result:
-            jamb['Error'] = "Processing "
-            logger.info(format % jamb)
-            jamb_reg_no = jamb.get(csv_d['jamb_reg_no'])
-            res = self.portal_catalog({'portal_type': "StudentApplication",
-                                     'SearchableText': jamb_reg_no })
+        for result in results:
+            #result['Error'] = "Processing "
+            #logger.info(format % result)
+            jamb_reg_no = result.get(csv_d['jamb_reg_no'])
+            res = self.students_catalog(jamb_reg_no = jamb_reg_no)
             if res:
                 em = 'Student with RegNo %s already exists\n' % jamb_reg_no
                 logger.info(em)
-                jamb['Error'] = "Student exists"
-                no_import.append(format % jamb)
-                continue
-            cert_id = makeCertificateCode(jamb.get(csv_d['course_code']))
+                result['Error'] = "Student exists"
+                no_import.append(format % result)
+                continue
+            cert_id = makeCertificateCode(result.get(csv_d['study_course']))
             if cert_id not in certs.keys():
-                em = 'No Certificate with ID %s \n' % cert_id
-                logger.info(em)
-                jamb['Error'] = "No Certificate %s" % cert_id
-                no_import.append( format % jamb)
-                continue
-            res = self.portal_pumeresults(jamb_reg_no = jamb_reg_no)
-            if len(res) == 1:
-                self.portal_pumeresults.modifyRecord(jamb_reg_no = jamb_reg_no,
-                                                     status = jamb.get(csv_d['stud_status']),
-                                                     )
-            jamb_reg_no =jamb.get(csv_d['jamb_reg_no'])
+                res = self.portal_catalog(meta_type = "Certificate",id = cert_id)
+                if not res:
+                    em = 'No Certificate with ID %s \n' % cert_id
+                    logger.info(em)
+                    result['Error'] = "No Certificate %s" % cert_id
+                    no_import.append( format % result)
+                    continue
+                cert = res[0]
+                cert_path = cert.getPath().split('/')
+                certificate = certs[cert_id] = {'faculty': cert_path[-4],
+                                     'department': cert_path[-3]}
             cert_doc = certs[cert_id]
             catalog_entry = {}
             catalog_entry['jamb_reg_no'] = jamb_reg_no
-            jamb_name = jamb.get(csv_d['jamb_lastname'])
-            jamb_name.replace('>','')
-            jamb_name.replace('<','')
-            names = jamb_name.split()
-            letter = names[-1][0].upper()
-            sid = self.generateStudentId(letter)
-            not_created = True
-            while not_created:
-                try:
-                    students_folder.invokeFactory('Student', sid)
-                    not_created = False
-                except BadRequest:
-                    sid = self.generateStudentId(letter)
+            firstname = result.get(csv_d['jamb_firstname'])
+            middlename = result.get(csv_d['jamb_middlename'])
+            lastname = result.get(csv_d['jamb_lastname'])
+            sid = self.generateStudentId('x')
+            students_folder.invokeFactory('Student', sid)
             catalog_entry['id'] = sid
             tr_count += 1
@@ -632,71 +614,46 @@
             student = getattr(self,sid)
             student.manage_setLocalRoles(sid, ['Owner',])
-            student.invokeFactory('StudentPume','pume')
-            dp = {'Title': 'Pume Data'}
             student.invokeFactory('StudentApplication','application')
             da = {'Title': 'Application Data'}
-            da["jamb_lastname"] = jamb_name
+            da["jamb_firstname"] = firstname
+            da["jamb_middlename"] = middlename
+            da["jamb_lastname"] = lastname
+            catalog_entry['entry_session'] = da["entry_session"] = self.getSessionId()[-2:]
+            catalog_entry['entry_level'] = da["entry_level"] = 'NA'
+            catalog_entry['sex'] = sex = result.get(csv_d['jamb_sex']).startswith('F')
             da_fields = ('jamb_reg_no',
                          'jamb_sex',
-                         #'jamb_state',
-                         'jamb_score',
-##                         'jamb_first_cos',
-                         'jamb_sex',
                          'jamb_state',
-                         'jamb_lga',
+                         'entry_mode',
                          'app_email',
-                         'app_mobile',
                          )
             for f in da_fields:
-                da[f] = jamb.get(csv_d[f])
-            catalog_entry['email'] = jamb.get(csv_d['app_email'])
+                da[f] = result.get(csv_d[f])
+            catalog_entry['email'] = da['app_email']
+            catalog_entry['entry_mode'] = da['entry_mode']
             app = student.application
             app_doc = app.getContent()
+            app.getContent().edit(mapping=da)
             picture ="%s/import/pictures/%s.jpg" % (i_home,jamb_reg_no)
-            #import pdb;pdb.set_trace()
-            if os.path.exists(picture):
-                file = open(picture)
-                if False:
-                    img = PIL.Image.open(file)
-                    img.thumbnail((150,200),
-                                  resample=PIL.Image.ANTIALIAS)
-                    # We now need a buffer to write to. It can't be the same
-                    # as the inbuffer as the PNG writer will write over itself.
-                    outfile = StringIO()
-                    img.save(outfile, format=img.format)
-                else:
-                    outfile = file.read()
+            app.manage_setLocalRoles(sid, ['Owner',])
+            picture_id = da['jamb_reg_no'].replace('/','_')
+            file = None
+            for ext in ('jpg','JPG'):
+                picture ="%s/import/pictures/%s.%s" % (i_home,picture_id,ext)
+                if os.path.exists(picture):
+                    file = open(picture)
+                    break
+            if file is not None:
+                outfile = file.read()
                 app_doc.manage_addFile('passport',
                                        file=outfile,
                                        title="%s.jpg" % jamb_reg_no)
-            app.getContent().edit(mapping=da)
-            app.manage_setLocalRoles(sid, ['Owner',])
             #wftool.doActionFor(app,'close')
-            dp_fields = (
-                         #'pume_eng_score',
-                         #'pume_gen_score',
-                         'pume_tot_score',
-                         )
-            dp['pume_tot_score'] = jamb.get(csv_d['pume_tot_score']) or "No Option Shaded"
-            pume = student.pume
-            pume.getContent().edit(mapping=dp)
-            #wftool.doActionFor(pume,'close')
-            pume.manage_setLocalRoles(sid, ['Owner',])
-            #student.getContent().createSubObjects()
             dp = {}
-            if len(names) == 3:
-                dp['firstname'] = names[0].capitalize()
-                dp['middlename'] = names[1].capitalize()
-                dp['lastname'] = names[2].capitalize()
-            elif len(names) == 2:
-                dp['firstname'] = names[0].capitalize()
-                dp['middlename'] = ''
-                dp['lastname'] = names[1].capitalize()
-            else:
-                dp['firstname'] = ''
-                dp['middlename'] = ''
-                dp['lastname'] = jamb_name
-            dp['sex'] = jamb.get(csv_d['jamb_sex']) == 'F'
-            catalog_entry['sex'] = dp['sex']
+            dp['firstname'] = firstname
+            dp['middlename'] = middlename
+            dp['lastname'] = lastname 
+            dp['email'] = da['app_email']
+            dp['sex'] = sex
             catalog_entry['name'] = "%(firstname)s %(middlename)s %(lastname)s" % dp
             student.invokeFactory('StudentPersonal','personal')
@@ -705,11 +662,6 @@
             per_doc.edit(mapping = dp)
             per.manage_setLocalRoles(sid, ['Owner',])
-            if jamb.get(csv_d['stud_status']) == "Admitted":
-                wftool.doActionFor(student,'pume_pass')
-                wftool.doActionFor(student,'admit')
-            else:
-                wftool.doActionFor(student,'pume_fail')
-                wftool.doActionFor(student,'reject_admission')
-                continue
+            wftool.doActionFor(student,'pume_pass')
+            wftool.doActionFor(student,'admit')
             #
             # Clearance
@@ -717,6 +669,12 @@
             student.invokeFactory('StudentClearance','clearance')
             #wftool.doActionFor(student.clearance,'open')
-            dp = {'Title': 'Clearance/Eligibility Record'}
-            student.clearance.manage_setLocalRoles(sid, ['Owner',])
+            clearance = student.clearance
+            dc = {'Title': 'Clearance/Eligibility Record'}
+            clearance = student.clearance
+            date_str = result.get(csv_d['birthday'])
+            date = DateTime.DateTime(date_str)
+            dc['birthday'] = date
+            clearance.getContent().edit(mapping=dc)
+            clearance.manage_setLocalRoles(sid, ['Owner',])
             #
             # Study Course
@@ -725,26 +683,15 @@
             study_course = student.study_course
             dsc = {}
-            #from_certificate = ['title',
-            #                   'max_elect',
-            #                   'max_pass',
-            #                   'n_core',
-            #                   'nr_years',
-            #                   'probation_credits',
-            #                   'promotion_credits',
-            #                   'start_level',
-            #                  ]
-            #for f in from_certificate:
-            #    dsc[f] = getattr(cert_doc,f)
-            #dsc['faculty'] = jamb.get(csv_d['faculty'])
-            #dsc['department'] = jamb.get(csv_d['department'])
-            catalog_entry['faculty'] = jamb.get(csv_d['faculty'])
-            catalog_entry['department'] = jamb.get(csv_d['department'])
-            catalog_entry['course'] = cert_id
             #catalog_entry['level'] = getattr(cert_doc,'start_level')
-            catalog_entry['level'] = '100'
-            dsc['study_course'] = cert_id
-            dsc['entry_level'] = '100'
-            #dsc['entry_session'] = jamb.get(csv_d['session'])
+            catalog_entry['session'] = dsc['current_session'] = da['entry_session']
+            catalog_entry['level'] = dsc['current_level'] = 'NA'
+            catalog_entry['mode'] = dsc['current_mode'] = da['entry_mode']
+            catalog_entry['course'] = dsc['study_course'] = cert_id
+            catalog_entry['faculty'] = certificate['faculty']
+            catalog_entry['department'] = certificate['department']
+            catalog_entry['verdict'] = dsc['current_verdict'] = 'NA'
+            catalog_entry['review_state'] = self.portal_workflow.getInfoFor(student,'review_state',None)
             study_course.getContent().edit(mapping=dsc)
+            #import pdb;pdb.set_trace()
             self.students_catalog.addRecord(**catalog_entry)
             if tr_count > 10:
Index: WAeUP_SRP/trunk/WAeUPTables.py
===================================================================
--- WAeUP_SRP/trunk/WAeUPTables.py	(revision 1706)
+++ WAeUP_SRP/trunk/WAeUPTables.py	(revision 1707)
@@ -231,19 +231,31 @@
     key = "id"
     affected_types = {   ###(
-                      'StudentApplication':
+                      'StudentApplication': 
+                          {'id': 'application',
+                           'fields':
                              ('jamb_reg_no',
                               'entry_mode',
+                              'entry_level',
                               'entry_session',
-                              ),
+                              )
+                              },
                       'StudentClearance':
+                          {'id': 'clearance',
+                           'fields':
                              ('matric_no',
-                              ),
+                              )
+                              },
                          'StudentPersonal':
+                          {'id': 'personal',
+                           'fields':
                              ('name',
                               'sex',
                               'email',
                               'phone',
-                              ),
+                              )
+                              },
                          'StudentStudyCourse':
+                          {'id': 'study_course',
+                           'fields':
                              ('course',
                               'faculty',
@@ -253,5 +265,6 @@
                               'session',
                               'verdict',
-                              ),
+                              )
+                              },
                          }
     ###)
@@ -380,5 +393,5 @@
             else:
                 for pt in self.affected_types.keys():
-                    if n in self.affected_types[pt]:
+                    if n in self.affected_types[pt]['fields']:
                         if reindextypes.has_key(pt):
                             reindextypes[pt].append(n)
@@ -395,4 +408,5 @@
             if pghandler: pghandler.report(i)
             student_brain = students[i]
+            student_object = student_brain.getObject()
             data = {}
             modified = False
@@ -401,30 +415,29 @@
                 modified = True
                 data['review_state'] = student_brain.review_state
-            if reindextypes:
-                query = Eq('path',student_brain.getPath())
-                sub_brains = aq_portal(query)
+            sub_objects = False
+            for pt in reindextypes.keys():
                 modified = True
-                spath = student_brain.getPath()
-                if len(sub_brains) > 1:
-                    for sub_brain in sub_brains:
-                        if not sub_brain.portal_type in reindextypes.keys():
-                            continue
-                        doc = sub_brain.getObject().getContent()
-                        for field in self.affected_types[sub_brain.portal_type]:
-                            if hasattr(self,'get_from_doc_%s' % field):
-                                data[field] = getattr(self,'get_from_doc_%s' % field)(doc)
-                            else:
-                                data[field] = getattr(doc,field)
-                elif len(sub_brains) == 1 and noattr:
-                    import_res = self.returning_import(id = sid)
-                    if not import_res:
-                        continue
-                    import_record = import_res[0]
-                    data['matric_no'] = import_record.matric_no
-                    data['sex'] = import_record.Sex == 'F'
-                    data['name'] = "%s %s %s" % (import_record.Firstname,
-                                                 import_record.Middlename,
-                                                 import_record.Lastname)
-                    data['matric_no'] = import_record.Entryregno
+                try:
+                    doc = getattr(student_object,self.affected_types[pt]['id']).getContent()
+                    sub_objects = True
+                except:
+                    continue
+                for field in self.affected_types[pt]['fields']:
+                    if hasattr(self,'get_from_doc_%s' % field):
+                        data[field] = getattr(self,'get_from_doc_%s' % field)(doc)
+                    else:
+                        data[field] = getattr(doc,field)
+                #from pdb import set_trace;set_trace()
+            if not sub_objects and noattr:
+                import_res = self.returning_import(id = sid)
+                if not import_res:
+                    continue
+                import_record = import_res[0]
+                data['matric_no'] = import_record.matric_no
+                data['sex'] = import_record.Sex == 'F'
+                data['name'] = "%s %s %s" % (import_record.Firstname,
+                                             import_record.Middlename,
+                                             import_record.Lastname)
+                data['matric_no'] = import_record.Entryregno
             if reindex_special and 'registered_courses' in reindex_special:
                 query = Eq('id','study_course') & Eq('path',student_brain.getPath())
@@ -480,17 +493,19 @@
             sid = data['id'] = student_brain.getId
             data['review_state'] = student_brain.review_state
-            sub_brains = self.portal_catalog(path = spath)
-            if len(sub_brains) > 1:
-                for sub_brain in sub_brains:
-                    if not sub_brain.portal_type in self.affected_types.keys():
-                        continue
-                    doc = sub_brain.getObject().getContent()
-                    for field in self.affected_types[sub_brain.portal_type]:
-                        if hasattr(self,'get_from_doc_%s' % field):
-                            data[field] = getattr(self,'get_from_doc_%s' % field)(doc)
-                        else:
-                            data[field] = getattr(doc,field)
-            elif len(sub_brains) == 1:
-                #import pdb;pdb.set_trace()
+            sub_objects = False
+            for pt in self.affected_types.keys():
+                modified = True
+                try:
+                    doc = getattr(student_object,self.affected_types[pt]['id']).getContent()
+                    sub_objects = True
+                except:
+                    continue
+                for field in self.affected_types[pt]['fields']:
+                    if hasattr(self,'get_from_doc_%s' % field):
+                        data[field] = getattr(self,'get_from_doc_%s' % field)(doc)
+                    else:
+                        data[field] = getattr(doc,field)
+                #from pdb import set_trace;set_trace()
+            if not sub_objects and noattr:
                 import_res = self.returning_import(id = sid)
                 if not import_res:
@@ -503,4 +518,27 @@
                                              import_record.Lastname)
                 data['matric_no'] = import_record.Entryregno
+##            sub_brains = self.portal_catalog(path = spath)
+##            if len(sub_brains) > 1:
+##                for sub_brain in sub_brains:
+##                    if not sub_brain.portal_type in self.affected_types.keys():
+##                        continue
+##                    doc = sub_brain.getObject().getContent()
+##                    for field in self.affected_types[sub_brain.portal_type]:
+##                        if hasattr(self,'get_from_doc_%s' % field):
+##                            data[field] = getattr(self,'get_from_doc_%s' % field)(doc)
+##                        else:
+##                            data[field] = getattr(doc,field)
+##            elif len(sub_brains) == 1:
+##                #import pdb;pdb.set_trace()
+##                import_res = self.returning_import(id = sid)
+##                if not import_res:
+##                    continue
+##                import_record = import_res[0]
+##                data['matric_no'] = import_record.matric_no
+##                data['sex'] = import_record.Sex == 'F'
+##                data['name'] = "%s %s %s" % (import_record.Firstname,
+##                                             import_record.Middlename,
+##                                             import_record.Lastname)
+##                data['matric_no'] = import_record.Entryregno
             study_course = getattr(student_obj,'study_course',None)
             current_level = data.get('level',None)
@@ -548,8 +586,7 @@
             return
         elif pt == 'CourseResult' and mt == 'CPS Proxy Folder':
-            from pdb import set_trace;set_trace()
-            
+            pass
         if event_type not in ('sys_modify_object'):
-            from pdb import set_trace;set_trace()
+            #from pdb import set_trace;set_trace()
             return
         if mt == 'CPS Proxy Folder':
Index: WAeUP_SRP/trunk/WAeUPTool.py
===================================================================
--- WAeUP_SRP/trunk/WAeUPTool.py	(revision 1706)
+++ WAeUP_SRP/trunk/WAeUPTool.py	(revision 1707)
@@ -42,5 +42,11 @@
 import transaction
 import csv,re,os
-
+from Products.AdvancedQuery import Eq, Between, Le,In
+
+def getObject(object,name):
+    if object.hasObject(name):
+        return getattr(object,name)
+    return None
+    
 class WAeUPTool(UniqueObject, SimpleItem, ActionProviderBase):
     """WAeUP tool"""
@@ -57,4 +63,8 @@
                      )
 
+    def rwrite(self,s):
+        response = self.REQUEST.RESPONSE
+        response.setHeader('Content-type','text/html; charset=ISO-8859-15')
+        response.write("%s<br />\r\n" % s)
 
     def generateStudentId(self,letter): ###(
Index: WAeUP_SRP/trunk/profiles/default/schemas/student_application.xml
===================================================================
--- WAeUP_SRP/trunk/profiles/default/schemas/student_application.xml	(revision 1706)
+++ WAeUP_SRP/trunk/profiles/default/schemas/student_application.xml	(revision 1707)
@@ -8,4 +8,5 @@
  <field name="entry_mode" meta_type="CPS String Field"/>
  <field name="entry_session" meta_type="CPS String Field"/>
+ <field name="entry_level" meta_type="CPS String Field"/>
   <field name="objection_date" meta_type="CPS DateTime Field"/>
   <field name="jamb_age" meta_type="CPS Int Field"/>
Index: WAeUP_SRP/trunk/profiles/default/students_catalog.xml
===================================================================
--- WAeUP_SRP/trunk/profiles/default/students_catalog.xml	(revision 1706)
+++ WAeUP_SRP/trunk/profiles/default/students_catalog.xml	(revision 1707)
@@ -40,4 +40,7 @@
   <indexed_attr value="level"/>
  </index>
+ <index name="entry_level" meta_type="FieldIndex">
+  <indexed_attr value="entry_level"/>
+ </index>
  <index name="mode" meta_type="FieldIndex">
   <indexed_attr value="mode"/>
@@ -64,4 +67,5 @@
  <column value="email"/>
  <column value="phone"/>
+ <column value="entry_level"/>
  <column value="level"/>
  <column value="mode"/>
Index: WAeUP_SRP/trunk/skins/waeup_default/getSessionId.py
===================================================================
--- WAeUP_SRP/trunk/skins/waeup_default/getSessionId.py	(revision 1706)
+++ WAeUP_SRP/trunk/skins/waeup_default/getSessionId.py	(revision 1707)
@@ -15,4 +15,6 @@
 now = DateTime.DateTime()
 if now.month() > 7:
-    return "%s" % now.year()
-return "%s" % (now.year() - 1)
+    s = "%s" % now.year()
+else:
+    s = "%s" % (now.year() - 1)
+return s
Index: WAeUP_SRP/trunk/skins/waeup_utilities/setNewEntryMode.py
===================================================================
--- WAeUP_SRP/trunk/skins/waeup_utilities/setNewEntryMode.py	(revision 1706)
+++ WAeUP_SRP/trunk/skins/waeup_utilities/setNewEntryMode.py	(revision 1707)
@@ -23,4 +23,6 @@
 setheader = request.RESPONSE.setHeader
 students = context.portal_url.getPortalObject().campus.students
+import logging
+logger = logging.getLogger('Skins.setNewEntryMode')
 
 def rwrite(s):
@@ -30,24 +32,50 @@
 brains = context.portal_catalog(portal_type = 'Student')
 count = 0
+commit_count = 0
 #set_trace()
+logger.info('setNewEntryMode start')
 for brain in brains:
     stud_obj = brain.getObject()
     try:     
         app_doc = stud_obj.application.getContent()
-        try: 
-            sc_doc = stud_obj.study_course.getContent()
-        except:
-            sc_doc = None
     except:
         continue
+    try: 
+        sc_doc = stud_obj.study_course.getContent()
+    except:
+        sc_doc = None
     em = getattr(app_doc,'entry_mode',None)
-    new_em = "%s_ft" % em.lower()
-    app_doc.edit(mapping={'entry_mode': new_em})
+    if em in ('ume_ft','de_ft'):
+        new_em = em
+    else:
+        new_em = "%s_ft" % em.lower()
+    if em in ('ume_ft','UME'):
+        el = "100"
+    elif em in ('de_ft','DE'):
+        el = "200"
+    app_doc.edit(mapping={'entry_mode': new_em,
+                          'entry_level': el})
+    sid = brain.getId
     if sc_doc:
         sc_doc.edit(mapping={'current_mode': new_em})
+        context.students_catalog.modifyRecord(id = sid, 
+                                              mode=new_em,
+                                              entry_mode=new_em,
+                                              entry_level=el)
+    else:
+        context.students_catalog.modifyRecord(id = sid, 
+                                              entry_mode=new_em,
+                                              entry_level=el)
+        
     count += 1
+    commit_count += 1
+    if commit_count > 1000:
+        context.waeup_tool.doCommit()
+        logger.info('committing %d total %d' % (commit_count,count))
+        commit_count = 0
     s = "%d: %s %s -> %s" % (count,brain.getPath(),em,new_em)
     rwrite(s)
 rwrite('Done')
+logger.info('setNewEntryMode finish')
 
 
