Changeset 621
- Timestamp:
- 09/10/05 05:14:04
- Files:
-
- trunk/cherrypy/test/test_tutorials.py (modified) (2 diffs)
- trunk/cherrypy/tutorial/ReturnVsYield.pdf (added)
- trunk/cherrypy/tutorial/tut09_files.py (moved) (moved from trunk/cherrypy/tutorial/tut09_file_upload.py) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/cherrypy/test/test_tutorials.py
r577 r621 145 145 '</body></html>') 146 146 147 def test09File Upload(self):148 self.load_tut_module("tut09_file _upload")147 def test09Files(self): 148 self.load_tut_module("tut09_files") 149 149 150 # Test upload 150 151 h = [("Content-type", "multipart/form-data; boundary=x"), 151 152 ("Content-Length", "110")] … … 165 166 </body> 166 167 </html>''') 168 169 # Test download 170 self.getPage('/download') 171 self.assertStatus("200 OK") 172 self.assertHeader("Content-Type", "application/x-download") 173 self.assertHeader("Content-Disposition", "attachment; filename=ReturnVsYield.pdf") 174 self.assertEqual(len(self.body), 326111) 167 175 168 176 if __name__ == "__main__": trunk/cherrypy/tutorial/tut09_files.py
r619 r621 1 1 """Tutorial: File upload""" 2 2 3 import os 4 localDir = os.path.dirname(__file__) 5 absDir = os.path.join(os.getcwd(), localDir) 6 3 7 import cherrypy 8 from cherrypy.lib import cptools 4 9 5 10 6 class File UploadDemo(object):11 class FileDemo(object): 7 12 8 13 def index(self): … … 39 44 return out % (size, myFile.filename, myFile.type) 40 45 upload.exposed = True 46 47 def download(self): 48 path = os.path.join(absDir, "ReturnVsYield.pdf") 49 return cptools.serveFile(path, "application/x-download", 50 "attachment", os.path.basename(path)) 51 download.exposed = True 41 52 42 53 43 cherrypy.root = File UploadDemo()54 cherrypy.root = FileDemo() 44 55 45 56 if __name__ == '__main__':

