add a try catch around the staticstorage lookup, which can throw an exception

This commit is contained in:
Chris Dodge
2013-08-17 10:15:03 -04:00
parent 4f0dfb97cd
commit 033f922ec0
5 changed files with 33 additions and 2 deletions

View File

@@ -119,7 +119,15 @@ def replace_static_urls(text, data_directory, course_id=None):
elif course_id and modulestore().get_modulestore_type(course_id) != XML_MODULESTORE_TYPE:
# first look in the static file pipeline and see if we are trying to reference
# a piece of static content which is in the mitx repo (e.g. JS associated with an xmodule)
if staticfiles_storage.exists(rest):
exists_in_staticfiles_storage = False
try:
exists_in_staticfiles_storage = staticfiles_storage.exists(rest)
except Exception as err:
log.warning("staticfiles_storage couldn't find path {0}: {1}".format(
rest, str(err)))
if exists_in_staticfiles_storage:
url = staticfiles_storage.url(rest)
else:
# if not, then assume it's courseware specific content and then look in the
@@ -142,6 +150,7 @@ def replace_static_urls(text, data_directory, course_id=None):
return "".join([quote, url, quote])
return re.sub(
_url_replace_regex('/static/(?!{data_dir})'.format(data_dir=data_directory)),
replace_static_url,