0

I'm using Grappelli together with Filebrowser and I found a bug when uploading images with a file extension in uppercase(image.PNG). If they end in uppercase a thumbnail will be created everytime the filebrowser page is refreshed.

I found this method in the filebrowser package:

def handle_file_upload(path, file, site):
    """
    Handle File Upload.
    """

    uploadedfile = None
    try:
        file_path = os.path.join(path, file.name)
        uploadedfile = site.storage.save(file_path, file)
    except Exception, inst:
        raise inst
    return uploadedfile

To solve the bug I want it to look like this:

def handle_file_upload(path, file, site):
        """
        Handle File Upload.
        """

        uploadedfile = None
        try:
            file_path = os.path.join(path, file.name.lower())
            uploadedfile = site.storage.save(file_path, file)
        except Exception, inst:
            raise inst
        return uploadedfile

How do I do this without changing the package file? I don't want my fix to disappeare when I update Filebrowser.

Can I override just that method? Or should I use signals or something?

Mogsdad
  • 44,709
  • 21
  • 151
  • 275
JOSEFtw
  • 9,781
  • 9
  • 49
  • 67

1 Answers1

0

I made my answer expling how to override a class method. but that's wrong... it is not a class method what you want to change.

I think, your best option is to make a branch in github of the project and then make a pull request and explein why you did it. If they share your opinion, they will take the pull request and you can go on without worry about override.

https://github.com/sehmaschine/django-filebrowser

Javier Vieira
  • 2,100
  • 20
  • 23
  • Yes I also think that's the best option...just wanted to make sure it doesn't exists any nice functions allowing me to override a third party package :) – JOSEFtw May 15 '14 at 14:35