import abc
class ConnectionRouterBase(abc.ABC):
@abstractmethod def db_for_read(self, model, **hints): ...
@abstractmethod def db_for_write(self, model, **hints): ...
@abstractmethod def allow_relation(self, obj1, obj2, **hints): ...
@abstractmethod def allow_migrate(self, db, app_label, **hints): ...A router doesn’t have to provide all these methods – it may omit one or more of them. If one of the methods is omitted, Django will skip that router when performing the relevant check.
abstract base class
Abstract base classes complement duck-typing by providing a way to define interfaces when other techniques like hasattr() would be clumsy or subtly wrong (for example with magic methods).
--
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-develop...@googlegroups.com.
To post to this group, send email to django-d...@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/c0e572d8-9075-4061-9c3b-e5074db2159e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
I don't think this would be that helpful, Django relies on ducktyping, and the router docs ( https://docs.djangoproject.com/en/2.2/topics/db/multi-db/ ) clearly document the signatures, and that the methods are all optional:A router doesn’t have to provide all these methods – it may omit one or more of them. If one of the methods is omitted, Django will skip that router when performing the relevant check.
--
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-develop...@googlegroups.com.
To post to this group, send email to django-d...@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/CAJAwA%3DzhuM4OL0JzshGHQK2nLw9YL2aLtEjGqrQAOwyvYE6Wiw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.