Code

#20019 closed Cleanup/optimization (fixed)

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

Reported by: coolRR Owned by: nobody
Component: HTTP handling Version: master
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 coolRR 16 months ago.

Download all attachments as: .zip

Change History (4)

Changed 16 months ago by coolRR

comment:1 Changed 16 months ago by coolRR

  • Component changed from Uncategorized to HTTP handling
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Type changed from Uncategorized to Cleanup/optimization
  • Version changed from 1.5 to master

comment:2 Changed 16 months ago by aaugustin

  • Easy pickings set
  • Triage Stage changed from Unreviewed to Accepted

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 Changed 16 months ago by Aymeric Augustin <aymeric.augustin@…>

  • Resolution set to fixed
  • Status changed from new to closed

In ce76fbfc5a14b0dbfdf28badb4bff874c8286d48:

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

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

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.