learningequality/ka-lite — pull request #785 by bcipolli (2013-10-01 04:38:06+00:00)
Title: Minimize queries 1

Hit these in the process of debugging performance slowness for @gimick

Issue:
A number of our decorators (non-cached) search for information that rarely changes:
* If a facility has been created
* If the server has been registered
* What the default language is
* What the list of current languages is

Current solution:
* Rather than hit the database for each of these, and potentially block on DB read, store this information in the session object, and access from there.

Other changes:
* The main custom context processor was included twice, so the code ran twice for every request (fixed)
* Debug toolbar gives wrong results if CACHE_TIME != 0, so now make sure CACHE_TIME=0 if debug toolbar is on.

Testing:
* Manual tests on pages

Notes:
* This changes queries for serving homepage, topic pages, video pages, and exercise pages to ZERO.
![image](https://f.cloud.github.com/assets/4072455/1242841/eae536f6-2a52-11e3-94ec-a1fbaf9f56eb.png)
![image](https://f.cloud.github.com/assets/4072455/1242845/f6d367ee-2a52-11e3-903f-4b59dc17f0be.png)
![image](https://f.cloud.github.com/assets/4072455/1242848/008ac57a-2a53-11e3-96c8-4f136c4c9b6b.png)
![image](https://f.cloud.github.com/assets/4072455/1242853/09623e94-2a53-11e3-8c2c-813838f5c640.png)