Warning: Can't synchronize with repository "(default)" (Unsupported version control system "svn": No module named svn). Look in the Trac log for more information.

Changes between Version 2 and Version 3 of FileUploadTutorial


Ignore:
Timestamp:
11/12/05 18:09:40 (9 years ago)
Author:
luca
Comment:

Simplify total_data reading.

Legend:

Unmodified
Added
Removed
Modified
  • FileUploadTutorial

    v2 v3  
    8080                        raise cherrypy.HTTPRedirect(turbogears.url("/%s" % pagename)) 
    8181                 
    82                 total_data='' 
    83                 while True: 
    84                         data = upload_file.file.read(8192) 
    85                         if not data: 
    86                                 break 
    87                         total_data += data 
     82                data = upload_file.file.read() 
    8883                target_file_name = os.path.join(os.getcwd(),UPLOAD_DIR,upload_file.filename) 
    8984                try: 
     
    9287                except SQLObjectNotFound: 
    9388                        f = open(target_file_name, 'w') 
    94                         f.write(total_data) 
     89                        f.write(data) 
    9590                        f.close 
    9691                        turbogears.flash("File uploaded successfully: %s saved as : %s" % (upload_file.filename, target_file_name))