Changeset 12250 for main/waeup.ikoba/trunk/src/waeup/ikoba/documents
- Timestamp:
- 16 Dec 2014, 09:02:13 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.ikoba/trunk/src/waeup/ikoba/documents/batching.py
r12249 r12250 56 56 factory_name = 'waeup.PDFDocument' 57 57 58 location_fields = [] 59 additional_fields = ['class_name'] 60 additional_headers = ['class_name'] 61 58 62 mode = None 59 63 … … 99 103 return 100 104 105 def checkConversion(self, row, mode='ignore'): 106 """Validates all values in row. 107 """ 108 errs, inv_errs, conv_dict = super( 109 PDFDocumentProcessor, self).checkConversion(row, mode=mode) 110 # We need to check if the class_name corresponds with the 111 # processor chosen. This is to avoid accidentally wrong imports. 112 if mode != 'remove': 113 class_name = row.get('class_name', None) 114 if class_name != self.factory_name.strip('waeup.'): 115 errs.append(('class_name','wrong processor')) 116 # We have to check document_id. 117 document_id = row.get('document_id', None) 118 if mode == 'create': 119 if not document_id: 120 document_id = generate_document_id() 121 conv_dict['document_id'] = document_id 122 return errs, inv_errs, conv_dict 123 cat = queryUtility(ICatalog, name='documents_catalog') 124 results = list( 125 cat.searchResults(document_id=(document_id, document_id))) 126 if results: 127 # document_id must not exist. 128 errs.append(('document_id','id exists')) 129 else: 130 if not document_id.startswith('d'): 131 errs.append(('document_id','invalid format')) 132 return errs, inv_errs, conv_dict 133 101 134 102 135 class HTMLDocumentProcessor(PDFDocumentProcessor):
Note: See TracChangeset for help on using the changeset viewer.