> On 3 Jun 2021, at 12:03, N Aditya <gojeta.adi...@gmail.com> wrote:
> 
> 1. If atomic(using=...) is the way to go and the same has been implemented 
> for ORM queries as well, why introduce something like the routers framework 
> in the first place ?

You can meaningfully route individual ORM queries based on the model being 
queried and it's often useful to do so. So Django supports it.

It would be convenient to do the same for transaction blocks, but it isn't 
possible in a generally useful way because you don't know yet which models will 
be queried. So Django doesn't support it.

> 2. Also generally speaking, was the intention of building the routers 
> framework only to allow routing based on models and other hints available as 
> part of the args list

Yes, it was.

> or to expose hooks that can achieve routing of DB queries based on custom 
> logic that could either depend on the args list or not (The use-cases are 
> plenty. It can be from some state being pushed into a KV store based on some 
> logic that gets executed in the view etc., not just thread-local state. Also, 
> considering thread-local state here to be globals seems completely unfair 
> since in actuality, it is tied to the request's scope and not global for all 
> requests).

No, it wasn't.

> Also, if possible, I'd like to hear opinions about the above from the authors 
> of the routers framework as well. 

You could read what Russell wrote at that time:

https://github.com/django/django/commit/1b3dc8ad9a28486542f766ff93318aa6b4f5999b
https://code.djangoproject.com/ticket/12540
https://code.djangoproject.com/ticket/12541


> Also, I believe you quoted this in your previous message:
> > Indeed, you'd need something slightly smarter, but since connections are 
> > thread-local in Django, it should be manageable.
> 
> (...)

Let's say my proposal doesn't work, then. I didn't try it!

-- 
Aymeric.

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/35082C11-6797-43D9-9951-DC4935DEE62C%40polytechnique.org.

Reply via email to