Re: "things are ready" signal?

2008-10-02 Thread Malcolm Tredinnick


On Wed, 2008-10-01 at 23:04 +0200, Marc Fargas wrote:
> Hi there,
> 
> Staring at #8638 I'm trying to find a way to hook code to be run "just
> after Django is completelly loaded" and found no way ;(
> 
> The thing is, it's a really nice place to emit a signal if you want to
> do things "just after things are ready", but there's no signal for it.
> 
> And, as I found nowhere to hook the code for #8638 I have no idea of
> where such signal should be emitted from (or that code hooked).
> 
> So, would a signal there be useful? (no ticket filled yet) And, where
> can one hook code for that? :)

As pointed out elsewhere in the thread, your request is not very
well-defined. However, there is a more concrete idea in #5685 that has
some legs. Ben Slavin (__hawkeye__) and I have been discussing on and
off the need for something that basically runs after settings has been
loaded -- which is about as close as you can get to "before Django does
anything significant". The main usage for this is things like
registering cross-application signal handlers at the right time without
needing requirements like "this app must go after all other apps in the
list" (since as soon as you have two such apps, you cannot satisfy the
requirement). The other main usage I had in mind was for setting up
per-test changes that might be required.

That ticket is on my list of features to add, so now that we've branched
I can look at it again. It's not an entirely trivial patch, but I've
read it a couple of times in the past (and Ben and I worked on it
together at a sprint last year). I want to check we haven't missed
anything obvious now that a couple of months have gone by since I last
looked, but it should be ready and committed soon.

Regards,
Malcolm


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To post to this group, send email to django-developers@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-developers?hl=en
-~--~~~~--~~--~--~---



Re: "things are ready" signal?

2008-10-02 Thread James Bennett

On Wed, Oct 1, 2008 at 4:04 PM, Marc Fargas <[EMAIL PROTECTED]> wrote:
> The thing is, it's a really nice place to emit a signal if you want to
> do things "just after things are ready", but there's no signal for it.

Just after *what* is ready, precisely? After "import django" has
succeeded? After settings have been imported? After model caches have
been initialized? After a request handler has been instantiated (which
we already sort of have a signal for)?

This is one of many problems with a "Django is ready" signal --
everybody's going to have a use case which demands a different
definition of what "ready" means.

As it is, you have a signal which fires when we start processing an
HTTP request, and that's what most people should look to since Django
is, fundamentally, about cycles of HTTP request/HTTP response and so
that's the most useful mindset to have.

Failing that, there are plenty of well-established Python idioms for
"run this code once and only once the first time I'm imported", which
covers the remainder of the use cases (or really stubborn people who
want to act like Django is a desktop application instead of a web
framework).


-- 
"Bureaucrat Conrad, you are technically correct -- the best kind of correct."

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To post to this group, send email to django-developers@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-developers?hl=en
-~--~~~~--~~--~--~---



Re: "things are ready" signal?

2008-10-02 Thread Thomas Guettler

Marc Fargas schrieb:
> Hi there,
>
> Staring at #8638 I'm trying to find a way to hook code to be run "just
> after Django is completelly loaded" and found no way ;(
>   
...
> So, would a signal there be useful?
I am missing this signal, too.

 Thomas

-- 
Thomas Guettler, http://www.thomas-guettler.de/
E-Mail: guettli (*) thomas-guettler + de


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To post to this group, send email to django-developers@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-developers?hl=en
-~--~~~~--~~--~--~---



Re: "things are ready" signal?

2008-10-01 Thread Waylan Limberg

On Wed, Oct 1, 2008 at 5:04 PM, Marc Fargas <[EMAIL PROTECTED]> wrote:
>
>
> So, would a signal there be useful? (no ticket filled yet) And, where
> can one hook code for that? :)
>

I seem to recall this request being made from time to time. IIRC, it
always turned out that whoever asked didn't really want this, but
something else. Therefore, I don't believe anyone has provided a valid
use case for such a signal. I'd suggest searching the archives.



-- 

Waylan Limberg
[EMAIL PROTECTED]

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To post to this group, send email to django-developers@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-developers?hl=en
-~--~~~~--~~--~--~---