Add logging when info and about sections are missing

This commit is contained in:
Calen Pennington
2012-07-10 09:32:18 -04:00
parent 3011f3f336
commit ad08df7abd

View File

@@ -1,8 +1,12 @@
import logging
from path import path
from xmodule.modulestore import Location
from xmodule.seq_module import SequenceDescriptor, SequenceModule
from fs.errors import ResourceNotFoundError
log = logging.getLogger(__name__)
class CourseDescriptor(SequenceDescriptor):
module_class = SequenceModule
@@ -53,6 +57,7 @@ class CourseDescriptor(SequenceDescriptor):
with self.system.resources_fs.open(path("about") / section_key + ".html") as htmlFile:
return htmlFile.read()
except ResourceNotFoundError:
log.exception("Missing about section {key} in course {url}".format(key=section_key, url=self.location.url()))
return "! About section missing !"
elif section_key == "title":
return self.metadata.get('display_name', self.name)
@@ -81,6 +86,7 @@ class CourseDescriptor(SequenceDescriptor):
with self.system.resources_fs.open(path("info") / section_key + ".html") as htmlFile:
return htmlFile.read()
except ResourceNotFoundError:
log.exception("Missing info section {key} in course {url}".format(key=section_key, url=self.location.url()))
return "! About section missing !"
raise KeyError("Invalid about key " + str(section_key))