Re: registering app level signal handlers

2010-12-18 Thread Russell Keith-Magee
On Sun, Dec 19, 2010 at 5:55 AM, dmitry b wrote: > On Dec 18, 1:44 am, Łukasz Rekucki wrote: >>[...]The problem with putting signal handlers >> in __init__, is that it isn't the place you would really expect Model >> related code to live (like post_save). It can also lead to non-obvious >> cyclic

Re: registering app level signal handlers

2010-12-18 Thread dmitry b
On Dec 18, 1:44 am, Łukasz Rekucki wrote: >[...]The problem with putting signal handlers > in __init__, is that it isn't the place you would really expect Model > related code to live (like post_save). It can also lead to non-obvious > cyclic imports, 'cause your handler code will most likely need

Re: registering app level signal handlers

2010-12-18 Thread Łukasz Rekucki
Not every app needs/has urls.py to be included. "models.py" is imported Django's get_app(). So, something like admin.autodiscover() will also import your models. The problem with putting signal handlers in __init__, is that it isn't the place you would really expect Model related code to live (like

Re: registering app level signal handlers

2010-12-17 Thread Yaniv Aknin
Maybe I'm missing something here, but why not the app's __init__.py? (my main urls.py imports all my apps' urls.py, which means their __init__.py is likely to be called rather early in any request, no?) - Yaniv On Sat, Dec 18, 2010 at 3:10 AM, dmitry b wrote: > Aren't an app's models loaded l

Re: registering app level signal handlers

2010-12-17 Thread dmitry b
Aren't an app's models loaded lazily (upon the first use)? On Dec 16, 7:16 pm, "W. Craig Trader" wrote: > I usually register the signals for a given application at the bottom of that > app's model.py file. > > - Craig - -- You received this message because you are subscribed to the Google Group

Re: registering app level signal handlers

2010-12-16 Thread W. Craig Trader
I usually register the signals for a given application at the bottom of that app's model.py file. - Craig - On Thu, Dec 16, 2010 at 19:04, dmitry b wrote: > On Dec 16, 3:28 pm, Graham Dumpleton > wrote: > > On Friday, December 17, 2010 10:00:55 AM UTC+11, dmitry b wrote: > > > > Are you talkin

Re: registering app level signal handlers

2010-12-16 Thread dmitry b
On Dec 16, 3:28 pm, Graham Dumpleton wrote: > On Friday, December 17, 2010 10:00:55 AM UTC+11, dmitry b wrote: > > Are you talking about UNIX process signals? I'm sorry, I forgot there are two ways to interpret my question. It is about Django signals. -- You received this message because you a

Re: registering app level signal handlers

2010-12-16 Thread Steve Holden
On 12/16/2010 6:28 PM, Graham Dumpleton wrote: > Are you talking about UNIX process signals? > He's almost certainly talking about Django signals. I've never seen a definite recommendation as to how to do things exactly once early on in the life of your server process, so I am afraid I cannot off

Re: registering app level signal handlers

2010-12-16 Thread Graham Dumpleton
On Friday, December 17, 2010 10:00:55 AM UTC+11, dmitry b wrote: > > Hi, What is the best place to register a signal handler so that the > registration happens when the app is first initialized into django? I have > an app that needs to listen to signals generated by another app and fire off >

registering app level signal handlers

2010-12-16 Thread dmitry b
Hi, What is the best place to register a signal handler so that the registration happens when the app is first initialized into django? I have an app that needs to listen to signals generated by another app and fire off celery tasks in response. I've tried placing the registration code into the