Commit 4a288499 by ichuang

removed django.settings imports from modules/* ; changed debug prints

to use logging; added DEBUG attr to XModule class
parent b1ac441e
......@@ -37,6 +37,7 @@ class I4xSystem(object):
print "[courseware.module_render.I4xSystem] filestore path = %s" % filestore
self.render_function = render_function
self.exception404 = Http404
self.DEBUG = settings.DEBUG
def __repr__(self):
return repr(self.__dict__)
def __str__(self):
......
......@@ -16,7 +16,6 @@ import traceback
from lxml import etree
## TODO: Abstract out from Django
from django.conf import settings
from mitxmako.shortcuts import render_to_string
from x_module import XModule
......@@ -26,6 +25,8 @@ from multicourse import multicourse_settings
log = logging.getLogger("mitx.courseware")
#-----------------------------------------------------------------------------
class ComplexEncoder(json.JSONEncoder):
def default(self, obj):
if isinstance(obj, complex):
......@@ -202,7 +203,7 @@ class Module(XModule):
fp = self.filestore.open(self.filename)
except Exception,err:
print '[courseware.capa.capa_module.Module.init] error %s: cannot open file %s' % (err,self.filename)
if settings.DEBUG:
if self.DEBUG:
# create a dummy problem instead of failing
fp = StringIO.StringIO('<problem><text>Problem file %s is missing</text></problem>' % self.filename)
else:
......
import json
import logging
from django.conf import settings
from mitxmako.shortcuts import render_to_response, render_to_string
from x_module import XModule
from lxml import etree
log = logging.getLogger("mitx.courseware")
#-----------------------------------------------------------------------------
class Module(XModule):
id_attribute = 'filename'
......@@ -26,8 +30,8 @@ class Module(XModule):
filename="html/"+self.filename
return self.filestore.open(filename).read()
except: # For backwards compatibility. TODO: Remove
if settings.DEBUG:
print '[courseware.modules.html_module] filename=%s' % self.filename
if self.DEBUG:
log.info('[courseware.modules.html_module] filename=%s' % self.filename)
#return render_to_string(self.filename, {'id': self.item_id})
return render_to_string(self.filename, {'id': self.item_id},namespace='course')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment