Re: Signature of the allow_migrate database router.

2015-02-18 Thread Aymeric Augustin
2015-02-18 14:07 GMT+01:00 Loïc Bistuer : > Individual routers don't have a base class but we can add it to the master > router `django.db.router`. I've updated the PR with a > `router.allow_migrate_model` method. I don't know if we should document > this just yet. > Good. Unless I missed somethi

Re: Signature of the allow_migrate database router.

2015-02-18 Thread Marten Kenbeek
Loïc, the model_name is indeed the lower-case version of the object_name: https://github.com/django/django/blob/master/django/db/models/options.py#L203 On Wednesday, February 18, 2015 at 2:07:28 PM UTC+1, Loïc Bistuer wrote: > > Individual routers don't have a base class but we can add it to the

Re: Signature of the allow_migrate database router.

2015-02-18 Thread Loïc Bistuer
Individual routers don't have a base class but we can add it to the master router `django.db.router`. I've updated the PR with a `router.allow_migrate_model` method. I don't know if we should document this just yet. Internally we now treat anything other than `app_label` as a hint, but I guess

Re: Signature of the allow_migrate database router.

2015-02-18 Thread Aymeric Augustin
2015-02-18 6:34 GMT+01:00 Loïc Bistuer : > Another option would be to make the signature `allow_migrate(self, db, > app_label, model_name=None, **hints)` and to put the model class in the > hints dict, the same way we pass `instance` as hint to the other routers. Yes, that's what I wanted to sug

Re: Signature of the allow_migrate database router.

2015-02-17 Thread Loïc Bistuer
Another option would be to make the signature `allow_migrate(self, db, app_label, model_name=None, **hints)` and to put the model class in the hints dict, the same way we pass `instance` as hint to the other routers. That would make the 80% use-case less fiddly without any loss of functionality.

Re: Signature of the allow_migrate database router.

2015-02-17 Thread Loïc Bistuer
> On Feb 18, 2015, at 05:18, Andrew Godwin wrote: > > I am fine with the proposed change to allow better routing of > RunSQL/RunPython (though in the RunPython case people can easily do routing > inside the python code provided anyway, as you can see the DB aliases there). True although that

Re: Signature of the allow_migrate database router.

2015-02-17 Thread Andrew Godwin
e proposed fix for the release blocker > https://code.djangoproject.com/ticket/24351 suggests changing the > signature of the `allow_migrate` database router. > > > > From: > > def allow_migrate(self, db, model): > > > > To: > > def allow_migrate(self, db, app_l

Re: Signature of the allow_migrate database router.

2015-02-17 Thread Aymeric Augustin
On 17 févr. 2015, at 11:06, Loïc Bistuer wrote: > The proposed fix for the release blocker > https://code.djangoproject.com/ticket/24351 suggests changing the signature > of the `allow_migrate` database router. > > From: > def allow_migrate(self, db, model): > > To:

Re: Signature of the allow_migrate database router.

2015-02-17 Thread Loïc Bistuer
l=None in RunPython/SQL. > > On Tuesday, February 17, 2015 at 5:06:24 AM UTC-5, Loïc Bistuer wrote: > Hi all, > > The proposed fix for the release blocker > https://code.djangoproject.com/ticket/24351 suggests changing the signature > of the `allow_migrate` database rout

Re: Signature of the allow_migrate database router.

2015-02-17 Thread Tim Graham
el=None in RunPython/SQL. On Tuesday, February 17, 2015 at 5:06:24 AM UTC-5, Loïc Bistuer wrote: > > Hi all, > > The proposed fix for the release blocker > https://code.djangoproject.com/ticket/24351 suggests changing the > signature of the `allow_migrate` database router. > &g

Signature of the allow_migrate database router.

2015-02-17 Thread Loïc Bistuer
Hi all, The proposed fix for the release blocker https://code.djangoproject.com/ticket/24351 suggests changing the signature of the `allow_migrate` database router. From: def allow_migrate(self, db, model): To: def allow_migrate(self, db, app_label, model, **hints): We need to make a design