google-code-export / django-filebrowser

Automatically exported from code.google.com/p/django-filebrowser
Other
0 stars 0 forks source link

handle_file_upload traps exception but returns non-existent variable #333

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Try to upload a file to a directory that does not have proper permissions or 
causes any other exception in handle_file_upload

What is the expected output? What do you see instead?

Should either re-throw the exception so it can be caught by Django's error 
mechanisms or return an initialized variable

What revision of the FileBrowser are you using?
trunk

What version/revision of Django are you using?
1.2.4

Please provide any additional information below.

I modified my version of handle_file_upload per below:

def handle_file_upload(path, file):
    """
    Handle File Upload.
    """
    uploadedfile = None
    try:
        file_path = os.path.join(path, file.name)
        uploadedfile = default_storage.save(file_path, file)
    except Exception, inst:
        print "___filebrowser.functions.handle_file_upload(): could not save uploaded file"
        print "ERROR: ", inst
        print "___"
        raise inst
    return uploadedfile

you don't have to provide the "raise inst" line, but I put it in their because 
I want to get emails from Django about errors and have them get logged to 
django-db-log.

Original issue reported on code.google.com by tcla...@gmail.com on 14 Apr 2011 at 4:48

GoogleCodeExporter commented 9 years ago
fixed with r684

Original comment by sehmaschine on 30 May 2011 at 10:39