Changeset 4899 for waeup/trunk/src
- Timestamp:
- 27 Jan 2010, 11:41:24 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
waeup/trunk/src/waeup/browser/batchprocessing.txt
r4888 r4899 15 15 ... try: 16 16 ... button = browser.getControl(name=name, index=num) 17 ... if button.value == value:17 ... if button.value.endswith(value): 18 18 ... return button 19 19 ... except IndexError: … … 408 408 409 409 410 Pending files 411 ============= 412 413 When an error occurs during an import, two files are generated: a CSV 414 file with finished files and a CSV file with pending data. Both are 415 stored in the appropriate subdirectories in datacenter. We try to 416 create faculties, from which one already exists. 417 418 Go to datacenter page: 419 420 >>> browser.open('http://localhost/app/datacenter') 421 422 Prepare a CSV file for faculties: 423 424 >>> open('newfaculties.csv', 'wb').write( 425 ... """code,review_state,title,title_prefix 426 ... FAC1,static,Faculty 1,faculty 427 ... FAC4,static,Faculty 4,school 428 ... """) 429 430 Upload the file: 431 432 >>> import cStringIO 433 >>> browser.getLink('Upload data').click() 434 >>> filecontents = cStringIO.StringIO( 435 ... open('newfaculties.csv', 'rb').read()) 436 >>> filewidget = browser.getControl(name='uploadfile:file') 437 >>> filewidget.add_file(filecontents, 'text/plain', 'newfaculties.csv') 438 >>> browser.getControl(name='SUBMIT').click() 439 440 Step 1: start batch processing: 441 442 >>> browser.getLink('Batch processing').click() 443 >>> button = lookup_submit_value( 444 ... 'select', 'newfaculties_zope.mgr.csv', browser) 445 >>> button.click() 446 447 Step 2: select a processor and mode: 448 449 >>> importerselect = browser.getControl(name='importer') 450 >>> importerselect.getControl('Faculty importer').selected = True 451 >>> modeselect = browser.getControl(name='mode') 452 >>> modeselect.getControl(value='create').selected = True 453 >>> browser.getControl('Proceed to step 3...').click() 454 455 Step 3: Fix headerlines 456 457 As there should be no problem with the headers, we can immediately 458 perfom the import: 459 460 >>> browser.getControl('Perform import...').click() 461 462 One line could not be imported: 463 464 >>> print browser.contents 465 <!DOCTYPE html PUBLIC... 466 ... 467 ...Processing of 1 rows failed!... 468 ...Successfully processed 1 rows... 469 ... 470 471 Now there are two files as a result in datacenter storage's root and 472 ``finished`` dirs: 473 474 >>> pending_file = dc_path + '/newfaculties_zope.mgr.pending.csv' 475 >>> print open(pending_file).read() 476 title_prefix,--IGNORE--,code,title,--ERRORS-- 477 faculty,static,FAC1,Faculty 1,This object already exists. Skipping. 478 479 >>> finished_file = dc_path + '/finished/newfaculties_zope.mgr.finished.csv' 480 >>> print open(finished_file).read() 481 title_prefix,--IGNORE--,code,title 482 school,static,FAC4,Faculty 4 483 484 The finished-file contains the dataset we could import, while the 485 pending file contains the dataset that failed, appended by an error 486 message. 487 488 410 489 Clean up: 411 490
Note: See TracChangeset for help on using the changeset viewer.