App-loading reloaded - running code at startup

2013-12-30 Thread Aymeric Augustin
Hello, There’ve been lots of brainstorming on this topic. It is now tracked in this ticket: https://code.djangoproject.com/ticket/21676. I’ve also sent a pull request: https://github.com/django/django/pull/2128. There’s a consensus on the general idea: - AppConfigs are a good place for startup

Re: App-loading reloaded - running code at startup

2013-12-30 Thread Aymeric Augustin
On 30 déc. 2013, at 13:29, Aymeric Augustin wrote: > ## Solution 2.a — Require users to call django.setup() before they use the > ORM. setup() would configure the settings and populate the app registry. > (…) > I’m currently working on this and I’ll add a commit to the pull request > (which I’

Re: App-loading reloaded - running code at startup

2013-12-30 Thread Ryan Hiebert
On Mon, Dec 30, 2013 at 10:16 AM, Aymeric Augustin wrote: > The real question — is requiring django.setup() acceptable? Explicit is > better than implicit, after all… It's probably obvious to others, but where would that `django.setup()` be? -- You received this message because you are subscr

Re: App-loading reloaded - running code at startup

2013-12-30 Thread Bas Peschier
Op maandag 30 december 2013 17:16:21 UTC+1 schreef Aymeric Augustin: > > On 30 déc. 2013, at 13:29, Aymeric Augustin > > > wrote: > > [...] > > The real question — is requiring django.setup() acceptable? Explicit is > better than implicit, after all… > > As far as I can see only people who l

Re: App-loading reloaded - running code at startup

2013-12-30 Thread Aymeric Augustin
On 30 déc. 2013, at 17:37, Ryan Hiebert wrote: > It's probably obvious to others, but where would that `django.setup()` be? import django django.setup() Since setup() couples django.apps and django.conf, putting it into the django package seemed appropriate. -- Aymeric. -- You received thi

Re: App-loading reloaded - running code at startup

2013-12-30 Thread Anssi Kääriäinen
First, a big +1 for improved app-loading sequence. Problem 2: my vote for solution 2.b. This seems to be the most reliable way. Quick throwaway scripts will need two more lines of boilerplate code but that is easily worth the added reliability. I have a question about problem 1: Are model impor

Re: App-loading reloaded - running code at startup

2013-12-30 Thread Aymeric Augustin
On 30 déc. 2013, at 21:10, Anssi Kääriäinen wrote: > I have a question about problem 1: Are model imports going to be allowed from > app modules? I believe allowing this will cause problems later on. While it doesn’t seem especially useful and hardly a good practice, it’s currently possible. I

Re: App-loading reloaded - running code at startup

2013-12-30 Thread Marc Tamlyn
I would suggest that Anssi's issues with model loading ordering are helped best by having `django.setup()` and doing away with the magical "I created a Model subclass and my app registry hot populated" issues. The proposed solution 2a seems best to me. It has never been clear how Django initialised

Re: App-loading reloaded - running code at startup

2013-12-30 Thread Marc Tamlyn
On another note, if you're going to muck about with a model in an existing app (perhaps for a very good reason like Permission) the best way of doing that (IMO) would be to create a subclassed AppConfig, get the relevant model from Apps in the setup() method and modify it directly there (add fields

Re: App-loading reloaded - running code at startup

2013-12-30 Thread Aymeric Augustin
On 30 déc. 2013, at 21:51, Marc Tamlyn wrote: > doing away with the magical "I created a Model subclass and my app registry > hot populated" issues. > This is ModelBase.__new__, another scary beast I haven’t attacked yet :) -- Aymeric. -- You received this message because you are subscribed

Re: App-loading reloaded - running code at startup

2013-12-30 Thread Aymeric Augustin
On 30 déc. 2013, at 21:59, Marc Tamlyn wrote: > On another note, if you're going to muck about with a model in an existing > app (perhaps for a very good reason like Permission) the best way of doing > that (IMO) would be to create a subclassed AppConfig, get the relevant model > from Apps in t

Re: App-loading reloaded - running code at startup

2013-12-30 Thread Marc Tamlyn
Heh, I forgot that contribute to class isn't documented. On second thoughts, let's not document this unless we actually have a good API for it. On 30 Dec 2013 21:05, "Aymeric Augustin" wrote: > On 30 déc. 2013, at 21:59, Marc Tamlyn wrote: > > On another note, if you're going to muck about with

Re: App-loading reloaded - running code at startup

2013-12-30 Thread Russell Keith-Magee
Hi Aymeric, First off - a *huge* thanks for all the work your doing on app reloading. I can't begin to express how much gratitude I have for the work you're doing here. On Mon, Dec 30, 2013 at 8:29 PM, Aymeric Augustin < aymeric.augus...@polytechnique.org> wrote: > Hello, > > There’ve been lots

Re: App-loading reloaded - running code at startup

2013-12-30 Thread Daniel Lindsley
Aymeric, As with the others, I'd like to echo my thanks! Having spent a lot of time with the old AppCache, I think these are solid improvements. Just a couple thoughts/questions from me. On Problem #1, IMO, I'd prefer to see something akin to an ``AppConfig.setup`` (before anything i

Re: App-loading reloaded - running code at startup

2013-12-30 Thread Andreas Pelme
Aymeric, Your work is amazing and has improved Django so much. Your work on timezone support, the transaction overhaul and now this app changes makes my and a lot of other peoples experience with Django so much better. Thank you! 2013/12/30 Aymeric Augustin > ## Solution 2.a — Require users to