Opened 14 years ago

Closed 13 years ago

Last modified 11 years ago

#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 Russell Keith-Magee, 14 years ago

Resolution: duplicate
Status: newclosed

Closing as a duplicate of #3591, since signal instantiation is an issue of app startup.

comment:2 by anonymous, 13 years ago

Easy pickings: unset
Resolution: duplicate
Severity: Normal
Status: closedreopened
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 Aymeric Augustin, 13 years ago

Resolution: duplicate
Status: reopenedclosed

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.

comment:4 by Aymeric Augustin, 11 years ago

This was indeed fixed by app-loading, which landed in Django 1.7.

Note: See TracTickets for help on using tickets.
Back to Top