Opened 7 years ago

Closed 7 years ago

#29100 closed Bug (needsinfo)

Give useful feedback to developer if a bad url is used for a static file

Reported by: Håkan Lövdahl Owned by: nobody
Component: File uploads/storage Version: 2.0
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

in django/core/handlers/base.py there is a problem.
Sometimes when using the statichandler it throws an exception without any useful information.
I would like to propose an update the BaseHandler class

    def get_response(self, request):
        """Return an HttpResponse object for the given HttpRequest."""
        # Setup default url resolver for this thread
        set_urlconf(settings.ROOT_URLCONF)

        if self._middleware_chain is None:
            if self.__class__.__name__ == 'StaticFilesHandler':
                uri = '%s' % (request.get_full_path() )
                raise ValueError('Bad path for static file: %s' % uri)

This would help for keeping the test-outputs nice and clean.

Attachments (1)

base.patch (570 bytes ) - added by Håkan Lövdahl 7 years ago.

Download all attachments as: .zip

Change History (3)

by Håkan Lövdahl, 7 years ago

Attachment: base.patch added

comment:1 by Tim Graham, 7 years ago

What are the steps to reproduce the error?

comment:2 by Tim Graham, 7 years ago

Resolution: needsinfo
Status: newclosed

And as far as the solution goes, putting a mention of StaticFilesHandler in BaseHandler doesn't look appropriate.

Note: See TracTickets for help on using tickets.
Back to Top