On Thu, Apr 5, 2012 at 4:20 PM, bruno desthuilliers <bruno.desthuilli...@gmail.com> wrote: > On Apr 5, 3:11 pm, Tom Evans <tevans...@googlemail.com> wrote: >> >> OP: I have a couple of solutions. One of the first things the server >> does is import your settings, so if you load and parse your static >> data at that point, then you will have access to it from that point >> onwards. > > Please dont. Settings are, well, settings, and should contain as few > executable code as possible. >
I would disagree. If the running of your application depends upon static content loaded from disk, it may be best to load it in settings.py. If the code fails, your server fails to start (fail fast). In this particular place, it may make sense. The OP is talking about loading static XML files, parsing them into a Python structure, and making them available for all views, which require them to work. As an example, say you use shared hosting, and your host writes your DB credentials to an XML file in your webroot, readable only by the webserver. Would it be wrong to parse that XML file in settings.py, in order to produce the settings.DATABASES setting? Clearly not. Django deliberately makes this path available to developers - otherwise settings may as well come from a YAML file. It is up to you to determine whether it is right or wrong for your particular project. Cheers Tom -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.