Delay initializition of the MongoKeyStore until required
This commit is contained in:
@@ -160,9 +160,8 @@ class Command(BaseCommand):
|
||||
element_actions[e.tag](e)
|
||||
|
||||
for k in results:
|
||||
print k
|
||||
keystore.create_item(k, 'Piotr Mitros')
|
||||
keystore().create_item(k, 'Piotr Mitros')
|
||||
if 'data' in results[k]:
|
||||
keystore.update_item(k, results[k]['data'])
|
||||
keystore().update_item(k, results[k]['data'])
|
||||
if 'children' in results[k]:
|
||||
keystore.update_children(k, results[k]['children'])
|
||||
keystore().update_children(k, results[k]['children'])
|
||||
|
||||
@@ -7,6 +7,6 @@ def index(request):
|
||||
# FIXME (cpennington): These need to be read in from the active user
|
||||
org = 'mit.edu'
|
||||
course = '6002xs12'
|
||||
course = keystore.get_item(['i4x', org, course, 'Course', None])
|
||||
course = keystore().get_item(['i4x', org, course, 'Course', None])
|
||||
weeks = course.get_children()
|
||||
return render_to_response('index.html', {'weeks': weeks})
|
||||
|
||||
@@ -9,4 +9,13 @@ from __future__ import absolute_import
|
||||
from django.conf import settings
|
||||
from .mongo import MongoKeyStore
|
||||
|
||||
keystore = MongoKeyStore(**settings.KEYSTORE)
|
||||
_KEYSTORE = None
|
||||
|
||||
|
||||
def keystore():
|
||||
global _KEYSTORE
|
||||
|
||||
if _KEYSTORE is None:
|
||||
_KEYSTORE = MongoKeyStore(**settings.KEYSTORE)
|
||||
|
||||
return _KEYSTORE
|
||||
|
||||
Reference in New Issue
Block a user