Commit 7fbc4d7f by ichuang

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

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