On Tue, 2008-10-21 at 13:07 +0200, Thomas Guettler wrote: > Hi, > > what do you think about a signal which fires after the models > of an application where loaded?
Probably not necessary. > > Use case: > > Load static (never changing objects) from the database and make them > available > at module or class level. In my case I want to load some permissions and > make them > available as Permission instances at class level. I think this can be done with a feature I want to add for 1.1 (I want to add it as soon as I have time to re-review an existing patch). Ben Slavin wrote a patch a while back to add support for functions that are called once settings have been imported but before any other activity happens. That is basically a "before anything else, do this" point in the process. Primarily, it can be used to register signal handlers, but it also has uses exactly in the sort of cases you mention: any preliminary setup stuff that should be done once. The reason it doesn't need a "when models have been loaded" signal is because that signal is actually a little non-deterministic. Models are loaded lazily (due to a small design wart in the way admin validation is done right at the moment, that "lazy" loading is pretty early in the process right now; that will change at some point). Instead, you shouldn't worry about when/how loading happens and just load the data at the right moment -- if that involves using models, they will be loaded properly. Hence, using the post-settings functions. Ben's patch for that was pretty good and, last I looked, pretty much ready to go in. 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 -~----------~----~----~----~------~----~------~--~---