瀏覽代碼

[desktop] Return a broken path if we can't find a file

Erick Tryzelaar 10 年之前
父節點
當前提交
0f1e3ee
共有 1 個文件被更改,包括 9 次插入1 次删除
  1. 9 1
      desktop/core/src/desktop/lib/django_mako.py

+ 9 - 1
desktop/core/src/desktop/lib/django_mako.py

@@ -144,4 +144,12 @@ def static(path):
   """
   Returns the URL to a file using the staticfiles's storage engine
   """
-  return staticfiles_storage.url(path)
+  try:
+    return staticfiles_storage.url(path)
+  except ValueError:
+    # django.contrib.staticfiles raises a ValueError if the file we are looking
+    # for is not in the staticfiles directory. This will result in a 500 error
+    # in a mako script, which is a little unfriendly. Instead we'll return a
+    # path to a non-existing file so the template renders and we can see the
+    # missing file in the logs.
+    return settings.STATIC_URL + path