Index: WAeUP_SRP/base/WAeUPImport.py
===================================================================
--- WAeUP_SRP/base/WAeUPImport.py	(revision 3373)
+++ WAeUP_SRP/base/WAeUPImport.py	(revision 3374)
@@ -409,36 +409,4 @@
     required_modes = ('create','edit','remove')
 
-    def old_getStudentRecord(self,mapping): ###(
-        id_field_found = False
-        msg = ''
-        student_record = None
-        id_count = 0
-        for id_key in ('matric_no','id'):
-            id_field = mapping.get(id_key,'')
-            if id_field:
-                id_count += 1
-                search_key = id_key
-                search_field = id_field
-        while True:
-            #if id_count > 1:
-            #    msg = "both id and matric_no are provided"
-            #    break
-            if id_count == 0:
-                msg = "neither id nor matric_no provided"
-                break
-            query = Eq(search_key,search_field)
-            res = self.students_catalog.evalAdvancedQuery(query)
-            if res:
-                student_record = res[0]
-                if search_key == "matric_no":
-                    mapping['id'] = student_record.id
-                elif search_key == "id":
-                    mapping['matric_no'] = student_record.matric_no
-            else:
-                msg = "no student with %(search_key)s %(search_field)s" % vars()
-            break
-        return student_record,msg
-    ###)
-
     def create(self,mapping):###(
         students_folder = self.portal_url.getPortalObject().campus.students
@@ -462,5 +430,4 @@
                 break
             result = self.findStudent('create',student_id=id,matric_no=matric_no)
-            #student_record,msg = self.getStudentRecord(mapping)
             msg = result['msg']
             if msg:
@@ -500,68 +467,11 @@
     ###)
 
-    def create_old(self,mapping):###(
-        students_folder = self.portal_url.getPortalObject().campus.students
-        if getattr(self,'_v_courses',None) is None:
-            res = self.courses_catalog()
-            self._v_courses = {}
-            for brain in res:
-                self._v_courses[brain.code] = brain
-        if getattr(self,'_v_level_created',None) is None:
-            self._v_level_created = []
+    def edit(self,mapping): ###(
         msg = ''
         key = ''
         matric_no = mapping.get('matric_no','')
-        student_id = mapping.get('id','')
-        while True:
-            course_id = mapping.get('code')
-            if course_id not in self._v_courses.keys():
-                msg = "no course with id: %s" % course_id
-                break
-            student_record,msg = self.getStudentRecord(mapping)
-            if msg:
-                break
-            student_id = student_record.id
-            level_id = mapping.get('level_id','')
-            code = mapping.get('code','')
-            if student_id not in self._v_level_created:
-                try:
-                    context = getattr(getattr(students_folder,
-                                            "%(student_id)s" % vars()),
-                                    'study_course')
-                except:
-                    msg = "could not create level %(level_id)s for %(student_id)s" % vars()
-                    break
-                if level_id not in context.objectIds():
-                    context.invokeFactory('StudentStudyLevel',"%(level_id)s" % vars())
-                    level = getattr(context,"%(level_id)s" % vars())
-                    self.portal_workflow.doActionFor(level,'open')
-                    # the session string must not be copied into the level object
-                    current_verdict = getattr(student_record,'current_verdict','')
-                    current_session = getattr(student_record,'current_session','')
-                    if current_verdict and student_record.current_level == level_id:
-                        level.getContent().edit(mapping={'verdict': "%s" %
-                                                        current_verdict,
-                                                        'session': "%s" %
-                                                        current_session,
-                                                        })
-                        self.portal_workflow.doActionFor(level,'close')
-                self._v_level_created += student_id,
-            mapping['key'] = key = "%(student_id)s|%(level_id)s|%(code)s" % vars()
-            for k in ('semester','credits',):
-                mapping[k] = getattr(self._v_courses[course_id],k)
-            try:
-                self.course_results.addRecord(**mapping)
-            except ValueError:
-                msg = "course result already exists: %s" % key
-            break
-        return key,msg,mapping
-    ###)
-
-    def edit(self,mapping): ###(
-        msg = ''
-        key = ''
+        id = mapping.get('id','')
         while True:
             result = self.findStudent('edit',student_id=id,matric_no=matric_no)
-            #student_record,msg = self.getStudentRecord(mapping)
             msg = result['msg']
             if msg:
@@ -584,8 +494,12 @@
         key = ''
         msg = ''
-        while True:
-            student_record,msg = self.getStudentRecord(mapping)
+        matric_no = mapping.get('matric_no','')
+        id = mapping.get('id','')
+        while True:
+            result = self.findStudent('edit',student_id=id,matric_no=matric_no)
+            msg = result['msg']
             if msg:
                 break
+            student_record = result['student_record']
             student_id = student_record.id
             level_id = mapping.get('level_id','')
@@ -1331,27 +1245,6 @@
             student_record = result['student_record']
             key_used = result['key_used']
-            # if student_id:
-            #     student_record = self.students_catalog.getRecordByKey(student_id)
-            #     if student_record is None:
-            #         #return '',"no student with id %s" % student_id
-            #         msg = "no student with id %s" % student_id
-            #         break
-            #     if matric_no and student_record.matric_no and matric_no != student_record.matric_no:
-            #         msg = 'student %s: matric_no %s does not match %s' % (student_record.id,
-            #                                                               student_record.matric_no,
-            #                                                               matric_no)
-            #         break
-            #     mapping['matric_no'] = student_record.matric_no
-            # elif matric_no:
-            #     res = self.students_catalog(matric_no = matric_no)
-            #     if not res:
-            #         msg = "no student with matric_no %s" % matric_no
-            #         break
-            #     student_record = res[0]
-            #     editable_keys.remove('matric_no')
-            # else:
-            #     msg = "no id or matric_no specified"
-            #     break
-            editable_keys.remove(key_used)
+            if key_used in editable_keys():
+                editable_keys.remove(key_used)
             student_id = student_record.id
             mapping['id'] = student_id
