Changeset 6828 for main/waeup.sirp/trunk/src/waeup/sirp/browser/pages.py
- Timestamp:
- 29 Sep 2011, 06:37:15 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.sirp/trunk/src/waeup/sirp/browser/pages.py
r6688 r6828 540 540 result = [] 541 541 num = 0 542 if not self.reader: 543 return 542 544 for row in self.reader: 543 545 if num > 4: … … 572 574 return parts[1] 573 575 576 def getWarnings(self): 577 import sys 578 result = [] 579 try: 580 headerfields = self.getPreviewHeader() 581 headerfields_clean = list(set(headerfields)) 582 if len(headerfields) > len(headerfields_clean): 583 result.append( 584 "Double headers: each column name may only appear once. ") 585 except: 586 fatal = '%s' % sys.exc_info()[1] 587 result.append(fatal) 588 if result: 589 warnings = "" 590 for line in result: 591 warnings += line + '<br />' 592 warnings += 'Replace imported file!' 593 return warnings 594 return False 595 574 596 def update(self, mode=None, importer=None, 575 597 back1=None, cancel=None, proceed=None): … … 596 618 return 597 619 self.fullpath = os.path.join(self.context.storage, self.filename) 598 self.reader = csv.DictReader(open(self.fullpath, 'rb')) 620 warnings = self.getWarnings() 621 if not warnings: 622 self.reader = csv.DictReader(open(self.fullpath, 'rb')) 623 else: 624 self.reader = () 625 self.flash(warnings) 599 626 600 627 class DatacenterImportStep3(WAeUPPage): … … 659 686 fatal = '%s' % sys.exc_info()[1] 660 687 result.append(fatal) 661 return result 688 if result: 689 warnings = "" 690 for line in result: 691 warnings += line + '<br />' 692 warnings += 'Edit headers or replace imported file!' 693 return warnings 694 return False 662 695 663 696 @property … … 689 722 self.redirect(self.url(self.context, '@@import4')) 690 723 return 691 692 724 self.importer = getUtility(IBatchProcessor, name=self.importername) 693 725 self.reader = csv.DictReader(open(self.fullpath, 'rb')) 726 warnings = self.getWarnings() 727 if warnings: 728 self.flash(warnings) 694 729 695 730 class DatacenterImportStep4(WAeUPPage):
Note: See TracChangeset for help on using the changeset viewer.