- Timestamp:
- 27 May 2009, 09:58:01 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
waeup/branches/ulif-rewrite/src/waeup/datacenter.py
r4184 r4186 157 157 return 'z%s' % struct.unpack('>Q', oid)[0] 158 158 159 def doImport(self, csvfile, receiverid, clear=None): 160 receivers = self.getReceiverIds() 161 if receiverid not in receivers.keys(): 162 raise ValueError('The requested data receiver cannot be found.') 163 receiver = receivers[receiverid] 164 importer = IWAeUPCSVImporter(receiver) 165 if clear is not None: 166 importer.doImport(csvfile, clear_old_data=clear) 167 else: 168 importer.doImport(csvfile) 169 return 170 159 171 160 172 class IDataCenterFile(Interface): … … 269 281 grok.require('waeup.manageUniversity') 270 282 grok.template('master') 283 grok.context(DataCenter) 271 284 272 285 def update(self, csvfile=None, clear=None, overwrite=None, … … 279 292 if not SUBMIT: 280 293 return 281 receivers = self.context.getReceiverIds() 282 if receiverid not in receivers.keys(): 283 return 284 receiver = receivers[receiverid] 285 importer = IWAeUPCSVImporter(receiver) 286 importer.doImport(csvfile) 294 try: 295 self.context.doImport(csvfile, receiverid, clear=clear) 296 except ValueError: 297 self.flash('Could not import: %s' % os.path.basename(csvfile)) 298 return 299 except: 300 self.flash('Import failed: %s' % sys.exc_info()[1]) 301 return 302 self.flash('Successfully imported: %s' % os.path.basename(csvfile)) 303 self.redirect(self.url(self.context)) 287 304 return 288 305 289 306 class Import(object): 307 """Helper class to aggregate imports and their data. 308 """ 290 309 def __init__(self, filedescr, importers): 291 310 self.file = filedescr
Note: See TracChangeset for help on using the changeset viewer.