Index: WAeUP_SRP/trunk/WAeUPTool.py
===================================================================
--- WAeUP_SRP/trunk/WAeUPTool.py	(revision 1721)
+++ WAeUP_SRP/trunk/WAeUPTool.py	(revision 1728)
@@ -63,4 +63,61 @@
                      )
 
+    student_field2types = {   ###(
+                      'StudentApplication': 
+                          {'id': 'application',
+                           'title': 'Application Data',
+                           'fields':
+                             ('jamb_reg_no',
+                              'entry_mode',
+                              'entry_level',
+                              'entry_session',
+                              'jamb_score',
+                              'email',
+                              'phone',
+                              )
+                              },
+                      'StudentPume':
+                          {'id': 'pume',
+                           'title': 'Pume Data',
+                           'fields':
+                             ('pume_score',
+                              )
+                              },
+                      'StudentClearance':
+                          {'id': 'clearance',
+                           'title': 'Clearance Data',
+                           'fields':
+                             ('matric_no',
+                              'entry_level',
+                              'entry_session',
+                              'nationality',
+                              'lga',
+                              )
+                              },
+                         'StudentPersonal':
+                          {'id': 'personal',
+                           'title': 'Personal Data',
+                           'fields':
+                             ('firstname',
+                              'middlename',
+                              'lastname',
+                              'sex',
+                              'email',
+                              'phone',
+                              )
+                              },
+                         'StudentStudyCourse':
+                          {'id': 'study_course',
+                           'title': 'Study Course',
+                           'fields':
+                             ('study_course',
+                              'current_level',
+                              'current_session',
+                              'current_verdict',
+                              )
+                              },
+                         }
+    ###)
+
     def rwrite(self,s):
         response = self.REQUEST.RESPONSE
@@ -199,73 +256,89 @@
         password = self.generatePassword()
         self.makeStudentMember(sid,password)
-        status,entry_mode = dict.get('entry_mode').split('_')
+        f2t = self.student_field2types
+        for pt in f2t.keys():
+            student_obj.invokeFactory(pt,f2t[pt]['id'])
+            sub_obj = getattr(student_obj,f2t[pt]['id'])
+            sub_doc = sub_obj.getContent()
+            self.portal_workflow.doActionFor(sub_obj,'open',dest_container=sub_obj)
+            d = {'Title': f2t[pt]['title']}
+            for field in f2t[pt]['fields']:
+                d[field] = dict.get(field,None) 
+            if pt == 'StudentPersonal':
+                d['sex'] = dict.get('sex') == 'F'
+            sub_doc.edit(mapping = d)
+            self.portal_workflow.doActionFor(sub_obj,'close',dest_container=sub_obj)
+            
+        entry_session = dict.get('entry_session')
         wfaction = 'return'
-        if status == "NEW":
+        if entry_session == self.getSessionId():
             wfaction = 'admit'
-        matric_no = dict.get('matric_no')
-        email = dict.get('email')
-        level = dict.get('level')
-        jamb_reg_no = dict.get('jamb_reg_no')
-        study_course = dict.get('study_course')
         self.portal_workflow.doActionFor(student_obj,wfaction)
         student_obj.manage_setLocalRoles(sid, ['Owner',])
-        student_obj.invokeFactory('StudentApplication','application')
-        application = student_obj.application
-        self.portal_workflow.doActionFor(application,'open',dest_container=application)
-        da = {'Title': 'Application Data'}
-        student_obj.invokeFactory('StudentPersonal','personal')
-        da['entry_mode'] = entry_mode
-        personal = student_obj.personal
-        self.portal_workflow.doActionFor(personal,'open',dest_container=personal)
-        dp = {'Title': 'Personal Data'}
-        student_obj.invokeFactory('StudentClearance','clearance')
-        clearance = student_obj.clearance
-        self.portal_workflow.doActionFor(clearance,'open',dest_container=clearance)
-        dc = {'Title': 'Clearance/Eligibility Record'}
-        dc['matric_no'] = matric_no
-        da['app_email'] = dp['email'] = email
-        da['jamb_reg_no'] = jamb_reg_no
-        dp['firstname'] = dict.get('firstname')
-        dp['middlename'] = dict.get('middlename')
-        dp['lastname'] = dict.get('lastname')
-        da['jamb_lastname'] = "%(firstname)s %(middlename)s %(lastname)s" % dict
-        sex = dict.get('sex')
-        if sex:
-            da['jamb_sex'] = 'F'
-        else:
-            da['jamb_sex'] = 'M'
-        dp['sex'] = sex
-        application.getContent().edit(mapping=da)
-        self.portal_workflow.doActionFor(application,'close',dest_container=application)
-        personal.getContent().edit(mapping=dp)
-        clearance.getContent().edit(mapping=dc)
-        self.portal_workflow.doActionFor(clearance,'close',dest_container=clearance)
-        catd = {}
-        catd['id'] = sid
-        catd['entry_mode']= entry_mode
-        catd['email'] = email
-        catd['jamb_reg_no'] = jamb_reg_no
-        catd['matric_no'] = matric_no
-        catd['name'] = "%(firstname)s %(middlename)s %(lastname)s" % dp
-        catd['sex'] = dp['sex']
-        catd['level'] = level
-        certificate_brain = self.getCertificateBrain(study_course)
-        if certificate_brain:
-            cpath = certificate_brain.getPath().split('/')
-            catd['faculty'] = cpath[-4]
-            catd['department'] = cpath[-3]
-            catd['course'] = study_course
-        self.students_catalog.addRecord(**catd)
-        #
-        # Study Course
-        #
-        student_obj.invokeFactory('StudentStudyCourse','study_course')
-        sc = student_obj.study_course
-        self.portal_workflow.doActionFor(sc,'open',dest_container=sc)
-        dsc = {}
-        dsc['study_course'] = study_course
-        dsc['current_level'] = level
-        sc.getContent().edit(mapping=dsc)
-
+##        matric_no = dict.get('matric_no')
+##        email = dict.get('email')
+##        #level = dict.get('level')
+##        jamb_reg_no = dict.get('jamb_reg_no')
+##        study_course = dict.get('study_course')
+##        self.portal_workflow.doActionFor(student_obj,wfaction)
+##        student_obj.manage_setLocalRoles(sid, ['Owner',])
+##        student_obj.invokeFactory('StudentApplication','application')
+##        application = student_obj.application
+##        self.portal_workflow.doActionFor(application,'open',dest_container=application)
+##        da = {'Title': 'Application Data'}
+##        student_obj.invokeFactory('StudentPersonal','personal')
+##        da['entry_mode'] = entry_mode
+##        personal = student_obj.personal
+##        self.portal_workflow.doActionFor(personal,'open',dest_container=personal)
+##        dp = {'Title': 'Personal Data'}
+##        student_obj.invokeFactory('StudentClearance','clearance')
+##        clearance = student_obj.clearance
+##        self.portal_workflow.doActionFor(clearance,'open',dest_container=clearance)
+##        dc = {'Title': 'Clearance/Eligibility Record'}
+##        dc['matric_no'] = matric_no
+##        da['app_email'] = dp['email'] = email
+##        da['jamb_reg_no'] = jamb_reg_no
+##        dp['firstname'] = dict.get('firstname')
+##        dp['middlename'] = dict.get('middlename')
+##        dp['lastname'] = dict.get('lastname')
+##        da['jamb_lastname'] = "%(firstname)s %(middlename)s %(lastname)s" % dict
+##        sex = dict.get('sex')
+##        if sex:
+##            da['jamb_sex'] = 'F'
+##        else:
+##            da['jamb_sex'] = 'M'
+##        dp['sex'] = sex
+##        application.getContent().edit(mapping=da)
+##        self.portal_workflow.doActionFor(application,'close',dest_container=application)
+##        personal.getContent().edit(mapping=dp)
+##        clearance.getContent().edit(mapping=dc)
+##        self.portal_workflow.doActionFor(clearance,'close',dest_container=clearance)
+####        catd = {}
+####        catd['id'] = sid
+####        catd['entry_mode']= entry_mode
+####        catd['email'] = email
+####        catd['jamb_reg_no'] = jamb_reg_no
+####        catd['matric_no'] = matric_no
+####        catd['name'] = "%(firstname)s %(middlename)s %(lastname)s" % dp
+####        catd['sex'] = dp['sex']
+####        catd['level'] = level
+####        certificate_brain = self.getCertificateBrain(study_course)
+####        if certificate_brain:
+####            cpath = certificate_brain.getPath().split('/')
+####            catd['faculty'] = cpath[-4]
+####            catd['department'] = cpath[-3]
+####            catd['course'] = study_course
+####        self.students_catalog.addRecord(**catd)
+##        #
+##        # Study Course
+##        #
+##        student_obj.invokeFactory('StudentStudyCourse','study_course')
+##        sc = student_obj.study_course
+##        self.portal_workflow.doActionFor(sc,'open',dest_container=sc)
+##        dsc = {}
+##        dsc['study_course'] = study_course
+##        #dsc['current_level'] = level
+##        sc.getContent().edit(mapping=dsc)
+##
         return sid,password
     ###)
