Changeset 1875 for WAeUP_SRP/trunk
- Timestamp:
- 10 Jun 2007, 16:42:46 (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
WAeUP_SRP/trunk/WAeUPTool.py
r1869 r1875 810 810 jamb_reg_no = mapping.get('jamb_reg_no',None) 811 811 matric_no = mapping.get('matric_no',None) 812 editable_keys = mapping.keys() 812 813 if sid: 813 814 res = self.students_catalog(id = sid) … … 824 825 if not res: 825 826 return '',"no student with jamb_reg_no %s" % jamb_reg_no 827 editable_keys.remove('jamb_reg_no') 826 828 elif matric_no: 827 829 res = self.students_catalog(matric_no = matric_no) 828 830 if not res: 829 831 return '',"no student with matric_no %s" % matric_no 830 #elif jamb_reg_no and res[0].jamb_reg_no and\ 831 # jamb_reg_no != res[0].jamb_reg_no: 832 # return '%s' % res[0].id ,"student has no jamb_reg_no %s" % jamb_reg_no 833 832 editable_keys.remove('matric_no') 834 833 sid = res[0].id 835 834 student_obj = getattr(students_folder,sid) 836 835 f2t = self.student_field2types 837 836 d = {} 838 d['jamb_sex'] = 'M' 839 if mapping.get('sex'): 840 d['jamb_sex'] = 'F' 837 #import pdb;pdb.set_trace() 838 any_change = False 841 839 for pt in f2t.keys(): 842 sub_obj = getattr(student_obj,f2t[pt]['id'],None) 843 if sub_obj is None: 844 try: 845 student_obj.invokeFactory(pt,f2t[pt]['id']) 846 except: 847 continue 848 sub_obj = getattr(student_obj,f2t[pt]['id']) 849 sub_doc = sub_obj.getContent() 850 # self.portal_workflow.doActionFor(sub_obj,'open',dest_container=sub_obj) 851 d['Title'] = f2t[pt]['title'] 852 for field in f2t[pt]['fields']: 853 if not mapping.get(field,None): 854 continue 855 d[field] = mapping.get(field,'') 856 sub_doc.edit(mapping = d) 857 # new_state = f2t[pt]['wf_transition'] 858 # if new_state != "remain": 859 # self.portal_workflow.doActionFor(sub_obj,new_state,dest_container=sub_obj) 860 # wfaction = 'return' 861 # self.portal_workflow.doActionFor(student_obj,wfaction) 862 # student_obj.manage_setLocalRoles(sid, ['Owner',]) 863 return sid,'' 840 if pt == "student_application": 841 d['jamb_sex'] = 'M' 842 if mapping.get('sex'): 843 d['jamb_sex'] = 'F' 844 intersect = set(f2t[pt]['fields']).intersection(set(editable_keys)) 845 if intersect: 846 sub_obj = getattr(student_obj,f2t[pt]['id'],None) 847 if sub_obj is None: 848 try: 849 student_obj.invokeFactory(pt,f2t[pt]['id']) 850 except: 851 continue 852 sub_obj = getattr(student_obj,f2t[pt]['id']) 853 d['Title'] = f2t[pt]['title'] 854 sub_doc = sub_obj.getContent() 855 for field in intersect: 856 changed = False 857 if getattr(sub_doc,field) != mapping.get(field,''): 858 any_change = True 859 changed = True 860 d[field] = mapping.get(field,'') 861 if changed: 862 sub_doc.edit(mapping = d) 863 if any_change: 864 return sid,'' 865 else: 866 return sid,'not modified' 864 867 ###) 865 868 … … 915 918 return em 916 919 for item in items: 917 tr_count += 1918 920 if start: 919 921 start = False … … 952 954 imported.append(em) 953 955 logger.info("%(total_imported)d of %(total)d %(em)s" % vars()) 956 tr_count += 1 954 957 total_imported += 1 955 958 total += 1 956 if tr_count > 1000: 959 if total_imported and not total_imported % 100: 960 transaction.commit() 957 961 if len(not_imported) > 0: 958 962 open("%s/import/%s_not_imported%s.csv" % (i_home,filename,current),"a").write( … … 964 968 imported = [] 965 969 em = '%d transactions committed\n' % (tr_count) 966 transaction.commit()967 970 regs = [] 968 971 logger.info(em)
Note: See TracChangeset for help on using the changeset viewer.