- Timestamp:
- 13 Jun 2009, 14:15:24 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
waeup/branches/ulif-rewrite/src/waeup/browser.txt
r4276 r4278 199 199 ['myfaculties.csv'] 200 200 201 We create and upload also a CSV file containing departments: 202 203 >>> open('departments.csv', 'wb').write( 204 ... """code,title,title_prefix,faculty_code 205 ... LIT,Literature,Department,FA 206 ... SOC,Sociology,Department,FA 207 ... PHY,Physics,Department,FS 208 ... INF,Informatics,Department,FS 209 ... MAT,Math,Department,FS 210 ... """) 211 212 >>> browser.open('http://localhost/myuniversity/datacenter/upload') 213 >>> browser.getControl(name='uploadfile:file').add_file( 214 ... cStringIO.StringIO(open('departments.csv', 'rb').read()), 215 ... 'text/plain', 'mydepartments.csv') 216 >>> browser.getControl(name='SUBMIT').click() 217 218 We create and upload also a CSV file containing courses: 219 220 >>> open('courses.csv', 'wb').write( 221 ... """code,level,title,passmark,credits,semester,faculty,department 222 ... LI1,,Introduction to Literature I,40,2,1,FA,LIT 223 ... LI2,,Introduction to Literature II,40,2,2,FA,LIT 224 ... AN1,000,Analysis I,40,2,1,FS,MAT 225 ... AN2,000,Analysis II,40,2,2,FS,MAT 226 ... """) 227 228 >>> browser.open('http://localhost/myuniversity/datacenter/upload') 229 >>> browser.getControl(name='uploadfile:file').add_file( 230 ... cStringIO.StringIO(open('courses.csv', 'rb').read()), 231 ... 'text/plain', 'mycourses.csv') 232 >>> browser.getControl(name='SUBMIT').click() 233 234 201 235 202 236 Importing a CSV file … … 217 251 ...myfaculties.csv... 218 252 ...Faculty Importer... 253 ...mydepartments.csv... 254 ...Department Importer... 255 ...mycourses.csv... 256 ...Course Importer... 219 257 ... 220 258 … … 222 260 tell us what kind of importer is available for each. 223 261 224 We do import the faculty file by clicking on ``Import!``: 225 226 >>> facimport = browser.getControl('Import!') 262 We do import the faculty file by clicking on ``Import!`` next to the 263 appropriate file: 264 265 >>> facimport = browser.getControl('Import!', index=0) 227 266 >>> facimport.click() 228 267 … … 242 281 ... 243 282 283 We can also import the department data: 284 285 >>> browser.open('http://localhost/myuniversity/datacenter') 286 >>> browser.getLink('Import CSV data').click() 287 >>> browser.getControl('Import!', index=1).click() 288 289 >>> print browser.contents 290 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"... 291 ...Successfully imported: mydepartments.csv... 292 ... 293 294 We can also import the course data: 295 296 >>> browser.open('http://localhost/myuniversity/datacenter') 297 >>> browser.getLink('Import CSV data').click() 298 >>> browser.getControl('Import!', index=2).click() 299 300 >>> print browser.contents 301 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"... 302 ...Successfully imported: mycourses.csv... 303 ... 304 305 244 306 Clean up: 245 307
Note: See TracChangeset for help on using the changeset viewer.