Opened 12 years ago

Closed 12 years ago

#20019 closed Cleanup/optimization (fixed)

Set `HttpRequest.resolver_match` to `None` by default

Reported by: Ram Rachum Owned by: nobody
Component: HTTP handling Version: dev
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no

Description

Sometimes my app has to deal with a request which does not have a .resolver_match object for some reason.

In these cases, I suggest that .resolver_match will have a value of None rather than not existing. This makes for much more elegant testing whether it exists or not.

Trivial patch attached.

Attachments (1)

patch.txt (464 bytes ) - added by Ram Rachum 12 years ago.

Download all attachments as: .zip

Change History (4)

by Ram Rachum, 12 years ago

Attachment: patch.txt added

comment:1 by Ram Rachum, 12 years ago

Component: UncategorizedHTTP handling
Type: UncategorizedCleanup/optimization
Version: 1.5master

comment:2 by Aymeric Augustin, 12 years ago

Easy pickings: set
Triage Stage: UnreviewedAccepted

Django generally creates in __init__ all attributes that may be set later on. I'll set the attribute at the instance level rather than at the class level. This is a small oversight in b946db5241b924c72c1079ce30d9b368e2b82f07.

comment:3 by Aymeric Augustin <aymeric.augustin@…>, 12 years ago

Resolution: fixed
Status: newclosed

In ce76fbfc5a14b0dbfdf28badb4bff874c8286d48:

Fixed #20019 -- Ensured HttpRequest.resolver_match always exists.

Obviously it isn't set until the URL is resolved.

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