On 28 mar, 16:58, javatina <serge.i...@gmail.com> wrote: > I could formulate my question differently - is there such thing as an > application context in Django? Basically, the question is - when a web > application starts there is a number of things that needs to be > available any time any request. Some of them are really static in > nature - for example, pagination parameters;
They go into settings.py > some of them are more > dynamic - for example, menu options. > > Things get more interesting when such data are read from the database. > So far what I see is that all that stuff should be places in the > request context (hopefully cached). It can be done more elegantly if > custom context processor(s) are created. But we are still rely on > request contexts. Unless I am missing something? Yes : custom template tags and middlewares. > It seems that although request contexts combined with caching can > help, it is way too complex for the purposes of initializing the > application. Why so ? > Which leads me to another question - is there any callback mechanism > when Django application starts? There's nothing like "Django application start" - depending on the deployement options, there can be as many processes and / or threads as necessary serving your website. > I guess what I am looking is a place > to make one-time queries, store data in a static member - and viola, I > have my application context. The closest solution would be memoization, but you'll still have at least one query per process (can't tell about threads). Or using the cache, which is still IMHO the safest solution. FWIW, there are benefits from this "share nothing" architecture when it comes to scaling. My 2 cents -- 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.