#14916 closed Uncategorized (duplicate)
No proper initialization of models/signals/etc....
Reported by: | Pakal | Owned by: | nobody |
---|---|---|---|
Component: | Core (Other) | Version: | 1.2 |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
As discussed in http://groups.google.com/group/django-developers/browse_thread/thread/825c154c54f79ad9 ,
there is a real problem with the fact that, in production mode (mod_python, mod_wsgi...), no loading of installed applications occurs, contrarily to what we have in django's dev server.
This raises major issues, imo :
- silent errors in the signaling framework : if a module isn't explicitely loaded by a view during request processing, the signal connections it contains will never be performed, so it makes the whole signaling framework quite broken.
- no proper place to put startup code : a quick google search shows that people are multiplying awkward constructs to initialize their application, by putting code in settings.py (which is often loaded several times => problems), in urls.py (that's NOT the point of this module), in temporary ("one-shot") middlewares...
Wouldn't it be quite handier to give each application a chance to initialize at server (or rather, worker process) startup, by loading all models.py, or maybe better, all init.py from INSTALLED_APPS ?
Change History (4)
comment:1 by , 14 years ago
Resolution: | → duplicate |
---|---|
Status: | new → closed |
comment:2 by , 13 years ago
Easy pickings: | unset |
---|---|
Resolution: | duplicate |
Severity: | → Normal |
Status: | closed → reopened |
Type: | → Uncategorized |
UI/UX: | unset |
I'm sorry, but this issue is not a duplicate of issue #3591 - which doesn't deal with early import of models and signal setup.
Clearly at server startup, the first http requests are unlikely to trigger the import of all install apps, so signals might be issued whereas all their listeners aren't yet activated. Same for django models, whose relationship tree won't be complete...
That's a serious workflow issue imo, invalidating the principle of the signal system of django.
comment:3 by , 13 years ago
Resolution: | → duplicate |
---|---|
Status: | reopened → closed |
Please don't re-open tickets closed by core developers. As explained in the contributing guide, you should write to the django-developers mailing list instead.
Closing as a duplicate of #3591, since signal instantiation is an issue of app startup.