Ticket #3849: sage-3849_1.patch

File sage-3849_1.patch, 1.5 KB (added by TimothyClemans, 13 years ago)
  • sage/server/notebook/twist.py

    # HG changeset patch
    # User Timothy Clemans <timothy.clemans@gmail.com>
    # Date 1218720384 25200
    # Node ID 2f4522b66a9bf4ed589975e085a84e1156979f0c
    # Parent  71b5924ee4e49aa81352bece8092cb2ca297fe04
    #3849 1
    
    diff -r 71b5924ee4e4 -r 2f4522b66a9b sage/server/notebook/twist.py
    a b  
    304304        self.username = username
    305305       
    306306    def render(self, ctx):
    307         url = ctx.args['urlField'][0].strip()
    308307        dir = ''  # we will delete the directory below if it is used
    309         if url != '':
    310             # downloading a file from the internet
    311             filename = get_remote_file(url, verbose=True)
    312         else:
     308        if not 'fileField' in ctx.files:
     309            return http.RedirectResponse('/upload')
     310       
     311        if ctx.files['fileField'][0][0]:
    313312            # uploading a file from the user's computer
    314313            dir = tmp_dir()
    315314            filename = ctx.files['fileField'][0][0]
     
    320319            f.write(ctx.files['fileField'][0][2].read())
    321320            # TODO: Server blocking issues (?!)
    322321            f.close()
     322        elif ctx.args['urlField'][0]:
     323            # downloading a file from the internet
     324            filename = get_remote_file(ctx.args['urlField'][0].strip(), verbose=True)
     325        else:
     326            return http.RedirectResponse('/upload')
    323327
    324328        try:
    325329            try: