Opened 3 years ago

Closed 2 years ago

#21483 closed New feature (fixed)

[RFE] Add WSGI environ to request_started signal emission

Reported by: jag@… Owned by: anonymous
Component: Core (Other) Version: master
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: yes
Easy pickings: no UI/UX: no

Description

As written, the request_started signal cannot take into account any of the specifics of the aforementioned request in a connected handler. The signal provided args should add the WSGI environ to the emitted signal to allow connected handlers to act related to the request's context.

Pull request provided here: https://github.com/django/django/pull/1951

Change History (7)

comment:1 Changed 3 years ago by Unai Zalakain

Needs documentation: set
Needs tests: set
Patch needs improvement: unset
Triage Stage: UnreviewedAccepted

Suggestions noted on the PR! Assign this ticket to yourself if you are planning to work on it ;-)

comment:2 Changed 3 years ago by Joshua "jag" Ginsberg <jag@…>

Owner: changed from nobody to anonymous
Status: newassigned

comment:3 Changed 3 years ago by Joshua "jag" Ginsberg <jag@…>

PR amended with suggestions. Thanks!

comment:4 Changed 3 years ago by Aymeric Augustin

I'm wondering if whatever you're planning to do in the signal receiver wouldn't be better implemented in a middleware.

But maybe that's just my phobia of signals :)

comment:5 Changed 3 years ago by Joshua "jag" Ginsberg <jag@…>

For many (most?) cases, I'd agree with you - middleware has that explicitness, where as signals are automated magic. However the signal is the absolute earliest place to modify the handling of a request - for cases where middleware may even be too late, doing work with a signal handler could be the best option.

comment:6 Changed 2 years ago by Tim Graham

Needs documentation: unset
Needs tests: unset
Patch needs improvement: set

I left comments for improvement on the PR. Please uncheck "Patch needs improvement" when you update it, thanks.

comment:7 Changed 2 years ago by Tim Graham <timograham@…>

Resolution: fixed
Status: assignedclosed

In eb2af16c59c3014541e2ad8ca63e510bc076dd8b:

Fixed #21483 -- Added WSGI environ to kwargs sent to request_started signal.

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