Changeset 6259 for main/waeup.sirp/trunk/src/waeup/sirp/utils/batching.py
- Timestamp:
- 1 Jun 2011, 00:52:39 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.sirp/trunk/src/waeup/sirp/utils/batching.py
r6243 r6259 28 28 # Name used in pages and forms... 29 29 name = u'Non-registered base importer' 30 30 31 31 # Internal name... 32 32 util_name = 'baseimporter' 33 33 34 34 # Items for this processor need an interface with zope.schema fields. 35 35 iface = Interface 36 36 37 37 # The name must be the same as the util_name attribute in order to 38 38 # register this utility correctly. … … 41 41 # Headers needed to locate items... 42 42 location_fields = ['code', 'faculty_code'] 43 43 44 44 # A factory with this name must be registered... 45 45 factory_name = 'waeup.Department' … … 65 65 result.append(key) 66 66 return result 67 67 68 68 @property 69 69 def req(self): … … 80 80 return sorted(list(set( 81 81 self.location_fields + getFields(self.iface).keys()))) 82 82 83 83 def getHeaders(self, mode='create'): 84 84 return self.available_fields … … 107 107 result[replacement] = row[key] 108 108 return result 109 109 110 110 def getMapping(self, path, headerfields, mode): 111 111 """Get a mapping from CSV file headerfields to actually used … … 132 132 result[key] = converter 133 133 return result 134 134 135 135 def convertToTypes(self, row, converter_dict): 136 136 """Convert values in given row to destination type. … … 167 167 """ 168 168 raise NotImplementedError('method not implemented') 169 169 170 170 def getEntry(self, row, site): 171 171 """Get the parent object for the entry in ``row``. 172 172 """ 173 173 raise NotImplementedError('method not implemented') 174 174 175 175 def addEntry(self, obj, row, site): 176 176 """Add the entry given given by ``row`` data. … … 181 181 """Delete entry given by ``row`` data. 182 182 """ 183 raise NotImplementedError('method not implemented') 183 raise NotImplementedError('method not implemented') 184 184 185 185 def updateEntry(self, obj, row, site): … … 226 226 writer.writerow(row) 227 227 return 228 228 229 229 def doImport(self, path, headerfields, mode='create', user='Unknown', 230 230 logger=None): … … 238 238 239 239 temp_dir = tempfile.mkdtemp() 240 240 241 241 (base, ext) = os.path.splitext(path) 242 242 failed_path = os.path.join(temp_dir, "%s.pending%s" % (base, ext)) … … 254 254 finished_headers) 255 255 finished_writer.writerow(dict([(x,x) for x in finished_headers])) 256 256 257 257 num =0 258 258 num_warns = 0 … … 267 267 self.writeFailedRow(failed_writer, raw_row, conv_warnings) 268 268 continue 269 269 270 270 if mode == 'create': 271 271 if not self.parentsExist(row, site): … … 313 313 time_end = time.time() 314 314 timedelta = time_end - time_start 315 315 316 316 self.createLogfile(path, failed_path, num, num_warns, mode, user, 317 317 timedelta, logger=logger)
Note: See TracChangeset for help on using the changeset viewer.