#31949: Allow builtin view decorators to be applied directly to async views.
--------------------------------+-------------------------------------
     Reporter:  Michael Galler  |                    Owner:  Ben Lomax
         Type:  New feature     |                   Status:  assigned
    Component:  Core (Other)    |                  Version:  3.1
     Severity:  Normal          |               Resolution:
     Keywords:  async           |             Triage Stage:  Accepted
    Has patch:  1               |      Needs documentation:  0
  Needs tests:  0               |  Patch needs improvement:  1
Easy pickings:  0               |                    UI/UX:  0
--------------------------------+-------------------------------------
Changes (by Carlton Gibson):

 * needs_better_patch:  0 => 1


Comment:

 I'm still worried about the proposed approach on the
 [https://github.com/django/django/pull/13483 current PR].

 * It's quite complex. There's a utility function `sync_async_wrapper`
 which is called **inside** each decorator implementation, making it less
 readable in each case I think.
 * This also forces each implementation into the `process_request()`,
 `process_response()` pattern, rather than allowing that to be inline
 **and** ties the implementation of those as sync.

 Then:

 * The `contrib.auth` decorators and mixins aren't handled.
 * Each of the decorators has the `sync_and_async_middleware()` decorator
 applied (marking it as both async and sync capable) but the attributes set
 are never checked in the code anywhere.

 Marking as patch needs improvement again on that basis.

 I'll continue to look at this, and try and discuss with folks over the
 DjangoCon period this autumn but, I think:

 * In some cases (certainly for the mixins) implementing the async-switch
 inline in the same way as
 
[https://github.com/django/django/blob/0c3981eb5094419fe200eb46c71b5376a2266166/django/views/generic/base.py#L159-L166
 the `View.options` handler does now] would be feasible. (This would solve
 Roy's issue from the StackOverflow thread.)
 * For others, it would be worth looking at a wrapper around the decorator
 implementation that adjusts the wrapped callback, rather than having to
 call a helper. (For example,  `@xframe_options_deny` &co need a sync view,
 currently, but can be adapted by `BaseHandler` after that, if needed.)

-- 
Ticket URL: <https://code.djangoproject.com/ticket/31949#comment:21>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/010701831d3e76a7-574e12fe-9c99-40b4-a3ba-cd93585dc185-000000%40eu-central-1.amazonses.com.

Reply via email to