Re: Simplify middlewares (again) and get rid of process_view

2018-05-30 Thread Carl Meyer
On 5/16/18 10:49 AM, Florian Apolloner wrote:
> Hi Carl,
> 
> On Wednesday, May 16, 2018 at 5:58:02 AM UTC+2, Carl Meyer wrote:
> 
> I'm not sure this part is feasible. It's an intentional part of
> middleware design AFAIK (and useful) that middleware can modify
> request.path and have this modification respected in view resolution.
> 
> 
> my proposed urlresolver_factory takes the request as argument and should
> therefore allow for anything that the middleware would allow too -- are
> there any specific usecases you have in mind that would require a
> middleware?

Composing two different middleware that both alter request.path for
different purposes? This will require the site owner to manually compose
in their urlconf_factory.

I think your core proposal that the main middleware call layering should
run after view resolution instead of before it is probably a better
design for middleware in principle, but it needs work in a couple areas:

1. Motivating the change in a way that clarifies how it will benefit
typical Django users, sufficiently to justify the churn. What new
possibilities are unlocked by the change, and has there been demand for
those possibilities?
2. Fleshing out how a reasonable transition path for existing middleware
(including third-party middleware) would look.

It's too bad we didn't think about this possibility during the original
DEP5, to avoid multiple middleware changes within a few Django versions.

Carl

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers  (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-developers+unsubscr...@googlegroups.com.
To post to this group, send email to django-developers@googlegroups.com.
Visit this group at https://groups.google.com/group/django-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/679c0352-d374-a979-90e3-732ea619ac63%40oddbird.net.
For more options, visit https://groups.google.com/d/optout.


Re: Simplify middlewares (again) and get rid of process_view

2018-05-27 Thread Adam Johnson
I'm also in favour of simplifying away process_view . And having worked
with a multi-domain site that altered request.urlconf in a middleware, I
know the problems it can bring.

Carl's point about modifying request.path is interesting - if we're looking
to allow modifying it in the resolver step but not the middleware, would we
"seal" the request to error if it gets changed later?

On Wed, 16 May 2018 at 18:49, Florian Apolloner 
wrote:

> Hi Carl,
>
> On Wednesday, May 16, 2018 at 5:58:02 AM UTC+2, Carl Meyer wrote:
>>
>> I'm not sure this part is feasible. It's an intentional part of
>> middleware design AFAIK (and useful) that middleware can modify
>> request.path and have this modification respected in view resolution.
>>
>
> my proposed urlresolver_factory takes the request as argument and should
> therefore allow for anything that the middleware would allow too -- are
> there any specific usecases you have in mind that would require a
> middleware?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django developers (Contributions to Django itself)" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-developers+unsubscr...@googlegroups.com.
> To post to this group, send email to django-developers@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-developers.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-developers/3f216c46-c48d-4ff1-bd6a-dcc2fb090c43%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>


-- 
Adam

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers  (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-developers+unsubscr...@googlegroups.com.
To post to this group, send email to django-developers@googlegroups.com.
Visit this group at https://groups.google.com/group/django-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/CAMyDDM0AvzAsyDO9Wzz7aGe-b2SEd6jjxQFot54GDXCnD-hohg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Simplify middlewares (again) and get rid of process_view

2018-05-16 Thread Florian Apolloner
Hi Carl,

On Wednesday, May 16, 2018 at 5:58:02 AM UTC+2, Carl Meyer wrote:
>
> I'm not sure this part is feasible. It's an intentional part of 
> middleware design AFAIK (and useful) that middleware can modify 
> request.path and have this modification respected in view resolution. 
>

my proposed urlresolver_factory takes the request as argument and should 
therefore allow for anything that the middleware would allow too -- are 
there any specific usecases you have in mind that would require a 
middleware?

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers  (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-developers+unsubscr...@googlegroups.com.
To post to this group, send email to django-developers@googlegroups.com.
Visit this group at https://groups.google.com/group/django-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/3f216c46-c48d-4ff1-bd6a-dcc2fb090c43%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Simplify middlewares (again) and get rid of process_view

2018-05-15 Thread Carl Meyer
Hi Florian,

On 5/12/18 10:22 AM, Florian Apolloner wrote:

> After refactoring the middlewares to new-style middlewares as we have them 
> now, I am left with two pain points:
> 
>  * atomic requests are still special cased and not in a middleware
>  * process_view is as useless as always (it can neither alter nor convert 
> args/kwargs or the view)
> 
> To change this I am proposing the following changes:
> 
>  * Deprecate request.urlconf and provide a way to set the urlconf __before__ 
> the middleware chain is entered
>  * Resolve view before the middleware chain is entered

I'm not sure this part is feasible. It's an intentional part of
middleware design AFAIK (and useful) that middleware can modify
request.path and have this modification respected in view resolution.

Carl

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers  (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-developers+unsubscr...@googlegroups.com.
To post to this group, send email to django-developers@googlegroups.com.
Visit this group at https://groups.google.com/group/django-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/0c8e1164-931e-72a9-438c-c099fd7447ad%40oddbird.net.
For more options, visit https://groups.google.com/d/optout.