Changeset 3191
- Timestamp:
- 20 Feb 2008, 16:50:08 (17 years ago)
- Location:
- WAeUP_SRP
- Files:
-
- 22 edited
Legend:
- Unmodified
- Added
- Removed
-
WAeUP_SRP/base/WAeUPImport.py
r3185 r3191 55 55 required_modes = ('create',) 56 56 57 def __init__(self, mode,waeup_tool):57 def __init__(self,waeup_tool): 58 58 self.member = member = waeup_tool.portal_membership.getAuthenticatedMember() 59 59 self.import_date = DateTime.DateTime().strftime("%d/%m/%y %H:%M:%S") … … 68 68 self.courses_catalog = waeup_tool.courses_catalog 69 69 self.course_results = waeup_tool.course_results 70 self.mode = mode71 self.import_method = getattr(self, '%s' % mode,None)70 #self.mode = mode 71 # self.import_method = getattr(self, '%s' % mode,None) 72 72 errors = [] 73 if self.import_method is None:74 errors.append('No importer method %s' % mode)73 # if self.import_method is None: 74 # errors.append('No importer method %s' % mode) 75 75 self.pending_path = "%s/import/%s.pending" % (i_home,self.plural_name) 76 76 self.pending_tmp = "%s/import/%s.pending.tmp" % (i_home,self.plural_name) … … 96 96 info['imported_by'] = str(member) 97 97 info['import_date'] = self.import_date 98 info['import_mode'] = mode98 #info['import_mode'] = mode #now in import_xxx schema + layout 99 99 info['error'] = '' 100 100 #info['digest'] = '' -
WAeUP_SRP/base/WAeUPTool.py
r3186 r3191 1353 1353 if filename == pend_str: 1354 1354 pending_only = True 1355 mode = "create"1356 if edit:1357 if filename.endswith('_toDelete'):1358 mode = "delete"1359 else:1360 mode = "edit"1355 # mode = "create" 1356 # if edit: 1357 # if filename.endswith('_toDelete'): 1358 # mode = "delete" 1359 # else: 1360 # mode = "edit" 1361 1361 importer_name = ''.join([part.capitalize() for part in name.split('_')]) 1362 importer = eval("%sImport" % importer_name)( mode,self)1362 importer = eval("%sImport" % importer_name)(self) 1363 1363 logger = importer.logger 1364 1364 if importer.init_errors: 1365 logger.info( self.init_errors)1366 return self.init_errors1365 logger.info(importer.init_errors) 1366 return importer.init_errors 1367 1367 member = importer.member 1368 1368 current = importer.current … … 1423 1423 info['imported_from'] = import_source_fn 1424 1424 attrs = csv.reader(open(import_source_path,"rb")).next() 1425 if "import_mode" not in attrs: 1426 msg = 'import_mode must be in heading' 1427 return msg 1428 1425 1429 import_keys = [k.strip() for k in attrs if not (k.strip().startswith('ignore') 1426 1430 or k.strip() in info.keys())] … … 1430 1434 msg = 'not ignorable key(s): "%s" found in heading' % ", ".join(diff2schema) 1431 1435 return msg 1432 ifmode in importer.required_modes:1433 required_keys = [importer.layout.getIdUnprefixed(id)1434 for id,widget in importer.layout.objectItems()1435 if widget.is_required]1436 if not set(required_keys).issubset(set(import_keys)):1437 diff2import = set(required_keys).difference(set(import_keys))1438 msg = 'required key(s): "%s" not found in heading' % ", ".join(diff2import)1439 return msg1436 # if import_mode in importer.required_modes: 1437 # required_keys = [importer.layout.getIdUnprefixed(id) 1438 # for id,widget in importer.layout.objectItems() 1439 # if widget.is_required] 1440 # if not set(required_keys).issubset(set(import_keys)): 1441 # diff2import = set(required_keys).difference(set(import_keys)) 1442 # msg = 'required key(s): "%s" not found in heading' % ", ".join(diff2import) 1443 # return msg 1440 1444 # 1441 1445 # start importing … … 1467 1471 start = False 1468 1472 adapters = [MappingStorageAdapter(importer.schema, item)] 1469 logger.info('%(member)s starts import from %(import_source_fn)s in %(mode)s mode' % vars()) 1470 #logger.info('%s starts import from %s in %s mode with schema and layout %s' % (member,filename,mode,iname)) 1473 logger.info('%(member)s starts import from %(import_source_fn)s' % vars()) 1471 1474 dm = DataModel(item, adapters,context=self) 1472 1475 ds = DataStructure(data=item,datamodel=dm) … … 1474 1477 total += 1 1475 1478 error_count = 0 1476 for k in import_keys: 1477 if k not in item.keys() or k not in importer.validators.keys(): 1478 continue 1479 if not importer.validators[k](ds,mode=mode): 1480 if error_count: 1481 error_string += ' ++ ' 1482 error_string += "%s: %s" % (k,self.translation_service(ds.getError(k), 1479 import_mode = item.get('import_mode','edit') 1480 import_method = getattr(importer, '%(import_mode)s' % vars(),None ) 1481 if import_method is None: 1482 error_string += "no %(import_mode)s " % vars() 1483 else: 1484 for k in import_keys: 1485 if k not in item.keys() or k not in importer.validators.keys(): 1486 continue 1487 if not importer.validators[k](ds,mode=import_mode): 1488 if error_count: 1489 error_string += ' ++ ' 1490 error_string += "%s: %s" % (k,self.translation_service(ds.getError(k), 1483 1491 ds.getErrorMapping(k))) 1484 error_count += 11492 error_count += 1 1485 1493 if error_string: 1486 1494 error = error_string … … 1490 1498 temp_item = item.copy() 1491 1499 temp_item.update(dm) 1492 import_method = importer.import_method1493 if pending_only:1494 import_mode = temp_item.get('import_mode','edit')1495 import_method = getattr(importer, '%(import_mode)s' % vars() )1496 info['import_mode'] = import_mode1497 1500 results = import_method(temp_item) 1498 1501 id = results[0] … … 1567 1570 elapse = time.time() - elapse 1568 1571 copy2(pending_tmp,pending_path) 1569 msg = "finished importing in %(mode)s modefrom %(import_source_fn)s in %(elapse).2f seconds, " % vars()1572 msg = "finished importing from %(import_source_fn)s in %(elapse).2f seconds, " % vars() 1570 1573 msg += "%(count)d records totally read, %(total_added_to_imported)d added to %(imported_fn)s, " % vars() 1571 1574 if pending_only: -
WAeUP_SRP/uniben/profiles/default/layouts/import.xml
r3188 r3191 33 33 <property name="vocabulary">import_names</property> 34 34 </widget> 35 <widget name="mode" meta_type="Select Widget">36 <property name="title">Import Mode</property>37 <property name="fields">38 <element value="mode"/>39 </property>40 <property name="is_required">False</property>41 <property name="label">Import Mode</property>42 <property name="label_edit">Import Mode</property>43 <property name="readonly_layout_modes"/>44 <property name="hidden_layout_modes"/>45 <property name="hidden_readonly_layout_modes"/>46 <property name="vocabulary">import_modes</property>47 </widget>48 35 <table> 49 36 <row> -
WAeUP_SRP/uniben/profiles/default/layouts/import_application.xml
r2814 r3191 9 9 <property name="validate_values_expr"></property> 10 10 11 <widget name="import_mode" meta_type="Select Widget"> 12 <property name="title">Import Mode</property> 13 <property name="fields"> 14 <element value="import_mode"/> 15 </property> 16 <property name="is_required">True</property> 17 <property name="label">Import Mode</property> 18 <property name="label_edit">Import Mode</property> 19 <property name="readonly_layout_modes"/> 20 <property name="hidden_layout_modes"/> 21 <property name="hidden_readonly_layout_modes"/> 22 <property name="vocabulary">import_modes</property> 23 </widget> 11 24 <widget name="student_id" meta_type="String Widget"> 12 25 <property name="title">Student Id</property> -
WAeUP_SRP/uniben/profiles/default/layouts/import_certificate.xml
r2290 r3191 8 8 <property name="flexible_widgets"/> 9 9 <property name="validate_values_expr"></property> 10 <widget name="import_mode" meta_type="Select Widget"> 11 <property name="title">Import Mode</property> 12 <property name="fields"> 13 <element value="import_mode"/> 14 </property> 15 <property name="is_required">True</property> 16 <property name="label">Import Mode</property> 17 <property name="label_edit">Import Mode</property> 18 <property name="readonly_layout_modes"/> 19 <property name="hidden_layout_modes"/> 20 <property name="hidden_readonly_layout_modes"/> 21 <property name="vocabulary">import_modes</property> 22 </widget> 10 23 <widget name="title" meta_type="String Widget"> 11 24 <property name="fields"> -
WAeUP_SRP/uniben/profiles/default/layouts/import_certificate_course.xml
r2285 r3191 8 8 <property name="flexible_widgets"/> 9 9 <property name="validate_values_expr"></property> 10 <widget name="import_mode" meta_type="Select Widget"> 11 <property name="title">Import Mode</property> 12 <property name="fields"> 13 <element value="import_mode"/> 14 </property> 15 <property name="is_required">True</property> 16 <property name="label">Import Mode</property> 17 <property name="label_edit">Import Mode</property> 18 <property name="readonly_layout_modes"/> 19 <property name="hidden_layout_modes"/> 20 <property name="hidden_readonly_layout_modes"/> 21 <property name="vocabulary">import_modes</property> 22 </widget> 10 23 <widget name="Title" meta_type="String Widget"> 11 24 <property name="title">Title</property> -
WAeUP_SRP/uniben/profiles/default/layouts/import_course.xml
r2290 r3191 8 8 <property name="flexible_widgets"/> 9 9 <property name="validate_values_expr"></property> 10 <widget name="import_mode" meta_type="Select Widget"> 11 <property name="title">Import Mode</property> 12 <property name="fields"> 13 <element value="import_mode"/> 14 </property> 15 <property name="is_required">True</property> 16 <property name="label">Import Mode</property> 17 <property name="label_edit">Import Mode</property> 18 <property name="readonly_layout_modes"/> 19 <property name="hidden_layout_modes"/> 20 <property name="hidden_readonly_layout_modes"/> 21 <property name="vocabulary">import_modes</property> 22 </widget> 10 23 <widget name="code" meta_type="WAeUPId Widget"> 11 24 <property name="title">Course Id</property> -
WAeUP_SRP/uniben/profiles/default/layouts/import_course_result.xml
r3143 r3191 8 8 <property name="flexible_widgets"/> 9 9 <property name="validate_values_expr"></property> 10 <widget name="import_mode" meta_type="Select Widget"> 11 <property name="title">Import Mode</property> 12 <property name="fields"> 13 <element value="import_mode"/> 14 </property> 15 <property name="is_required">True</property> 16 <property name="label">Import Mode</property> 17 <property name="label_edit">Import Mode</property> 18 <property name="readonly_layout_modes"/> 19 <property name="hidden_layout_modes"/> 20 <property name="hidden_readonly_layout_modes"/> 21 <property name="vocabulary">import_modes</property> 22 </widget> 10 23 <widget name="student_id" meta_type="String Widget"> 11 24 <property name="title">Student Id</property> -
WAeUP_SRP/uniben/profiles/default/layouts/import_department.xml
r2267 r3191 8 8 <property name="flexible_widgets"/> 9 9 <property name="validate_values_expr"></property> 10 <widget name="import_mode" meta_type="Select Widget"> 11 <property name="title">Import Mode</property> 12 <property name="fields"> 13 <element value="import_mode"/> 14 </property> 15 <property name="is_required">True</property> 16 <property name="label">Import Mode</property> 17 <property name="label_edit">Import Mode</property> 18 <property name="readonly_layout_modes"/> 19 <property name="hidden_layout_modes"/> 20 <property name="hidden_readonly_layout_modes"/> 21 <property name="vocabulary">import_modes</property> 22 </widget> 10 23 <widget name="code" meta_type="WAeUPId Widget"> 11 24 <property name="title">Department Code</property> -
WAeUP_SRP/uniben/profiles/default/layouts/import_faculty.xml
r2267 r3191 8 8 <property name="flexible_widgets"/> 9 9 <property name="validate_values_expr"></property> 10 <widget name="import_mode" meta_type="Select Widget"> 11 <property name="fields"> 12 <element value="import_mode"/> 13 </property> 14 <property name="is_required">True</property> 15 <property name="label">Import Mode</property> 16 <property name="label_edit">Import Mode</property> 17 <property name="readonly_layout_modes"/> 18 <property name="hidden_layout_modes"/> 19 <property name="hidden_readonly_layout_modes"/> 20 <property name="vocabulary">import_modes</property> 21 </widget> 10 22 <widget name="title" meta_type="String Widget"> 23 <property name="title">Import Mode</property> 11 24 <property name="fields"> 12 25 <element value="title"/> -
WAeUP_SRP/uniben/profiles/default/layouts/import_student.xml
r3005 r3191 8 8 <property name="flexible_widgets"/> 9 9 <property name="validate_values_expr"></property> 10 10 <widget name="import_mode" meta_type="Select Widget"> 11 <property name="title">Import Mode</property> 12 <property name="fields"> 13 <element value="import_mode"/> 14 </property> 15 <property name="is_required">True</property> 16 <property name="label">Import Mode</property> 17 <property name="label_edit">Import Mode</property> 18 <property name="readonly_layout_modes"/> 19 <property name="hidden_layout_modes"/> 20 <property name="hidden_readonly_layout_modes"/> 21 <property name="vocabulary">import_modes</property> 22 </widget> 11 23 <widget name="id" meta_type="String Widget"> 12 24 <property name="title">Id</property> -
WAeUP_SRP/uniben/profiles/default/layouts/import_verdict.xml
r3143 r3191 8 8 <property name="flexible_widgets"/> 9 9 <property name="validate_values_expr"></property> 10 <widget name="import_mode" meta_type="Select Widget"> 11 <property name="title">Import Mode</property> 12 <property name="fields"> 13 <element value="import_mode"/> 14 </property> 15 <property name="is_required">True</property> 16 <property name="label">Import Mode</property> 17 <property name="label_edit">Import Mode</property> 18 <property name="readonly_layout_modes"/> 19 <property name="hidden_layout_modes"/> 20 <property name="hidden_readonly_layout_modes"/> 21 <property name="vocabulary">import_modes</property> 22 </widget> 10 23 <widget name="id" meta_type="String Widget"> 11 24 <property name="title">Id</property> -
WAeUP_SRP/uniben/profiles/default/schemas/import.xml
r1774 r3191 3 3 <field name="filename" meta_type="CPS String Field"/> 4 4 <field name="name" meta_type="CPS String Field"/> 5 <field name="import_or_edit" meta_type="CPS Boolean Field"/>6 5 </object> -
WAeUP_SRP/uniben/profiles/default/schemas/import_application.xml
r2788 r3191 2 2 <?xml-stylesheet type="text/xsl" href="schema.xsl"?> 3 3 <object name="import_application" meta_type="CPS Schema"> 4 <field name="import_mode" meta_type="CPS String Field"/> 4 5 <field name="course1" meta_type="CPS String Field"/> 5 6 <field name="course2" meta_type="CPS String Field"/> -
WAeUP_SRP/uniben/profiles/default/schemas/import_certificate.xml
r2285 r3191 2 2 <?xml-stylesheet type="text/xsl" href="schema.xsl"?> 3 3 <object name="certificate" meta_type="CPS Schema"> 4 <field name="import_mode" meta_type="CPS String Field"/> 4 5 <field name="title" meta_type="CPS String Field"/> 5 6 <field name="admin_status" meta_type="CPS String Field"/> -
WAeUP_SRP/uniben/profiles/default/schemas/import_certificate_course.xml
r2285 r3191 2 2 <?xml-stylesheet type="text/xsl" href="schema.xsl"?> 3 3 <object name="certificate_course" meta_type="CPS Schema"> 4 <field name="import_mode" meta_type="CPS String Field"/> 4 5 <field name="code" meta_type="CPS String Field" /> 5 6 <field name="certificate_code" meta_type="CPS String Field" /> -
WAeUP_SRP/uniben/profiles/default/schemas/import_course.xml
r2285 r3191 2 2 <?xml-stylesheet type="text/xsl" href="schema.xsl"?> 3 3 <object name="course" meta_type="CPS Schema"> 4 <field name="import_mode" meta_type="CPS String Field"/> 4 5 <field name="title" meta_type="CPS String Field"/> 5 6 <field name="department_code" meta_type="CPS String Field"/> -
WAeUP_SRP/uniben/profiles/default/schemas/import_course_result.xml
r2481 r3191 2 2 <?xml-stylesheet type="text/xsl" href="schema.xsl"?> 3 3 <object name="course_result" meta_type="CPS Schema"> 4 <field name="import_mode" meta_type="CPS String Field"/> 4 5 <field name="student_id" meta_type="CPS String Field"/> 5 6 <field name="matric_no" meta_type="CPS String Field"/> -
WAeUP_SRP/uniben/profiles/default/schemas/import_department.xml
r2267 r3191 2 2 <?xml-stylesheet type="text/xsl" href="schema.xsl"?> 3 3 <object name="import_department" meta_type="CPS Schema"> 4 <field name="import_mode" meta_type="CPS String Field"/> 4 5 <field name="code" meta_type="CPS String Field"/> 5 6 <field name="faculty_code" meta_type="CPS String Field"/> -
WAeUP_SRP/uniben/profiles/default/schemas/import_faculty.xml
r2267 r3191 2 2 <?xml-stylesheet type="text/xsl" href="schema.xsl"?> 3 3 <object name="import_faculty" meta_type="CPS Schema"> 4 <field name="import_mode" meta_type="CPS String Field"/> 4 5 <field name="code" meta_type="CPS String Field"/> 5 6 <field name="title" meta_type="CPS String Field"/> -
WAeUP_SRP/uniben/profiles/default/schemas/import_verdict.xml
r3092 r3191 2 2 <?xml-stylesheet type="text/xsl" href="schema.xsl"?> 3 3 <object name="import_verdict" meta_type="CPS Schema"> 4 <field name="import_mode" meta_type="CPS String Field"/> 4 5 <field name="id" meta_type="CPS String Field"/> 5 6 <field name="matric_no" meta_type="CPS String Field"/> -
WAeUP_SRP/uniben/profiles/default/vocabularies/import_names.xml
r3188 r3191 7 7 <property name="acl_write_roles">Manager</property> 8 8 <item key="student" msgid="">Student Data</item> 9 <item key="verdict" msgid="">Verdicts &Return</item>9 <item key="verdict" msgid="">Verdicts + Return</item> 10 10 <item key="faculty" msgid="">Faculty Data</item> 11 11 <item key="department" msgid="">Department Data</item>
Note: See TracChangeset for help on using the changeset viewer.