Commits

David Chambers committed aba3fd9

Moved logic responsible for generating `stylesheets` and `scripts` out of `_defaults`. These values don't change, so it's wasteful to recalculate them for each request.

Comments (0)

Files changed (2)

settings/__init__.py

 
 BASE_URL = utf8(BASE_URL.rstrip('/'))
 
+def _styles():
+    stylesheets = []
+    for media, filenames in CSS[1:]:
+        for filename in [filenames] if isinstance(filenames, basestring) else filenames:
+            stylesheets.append({'media': media, 'href': CSS[0] + filename})
+    return stylesheets
+
+CSS = _styles()
+
 DISPLAY_DATE_FORMAT = utf8(DISPLAY_DATE_FORMAT)
 DISPLAY_TIME_FORMAT = utf8(DISPLAY_TIME_FORMAT)
 
+JS = [JS[0] + _filename for _filename in JS[1:]]
+
 MARKDOWN_DATE_FORMAT = u'%d %B %Y' # e.g. 2 April 2010
 MARKDOWN_TIME_FORMAT = u'%I:%M%p' # e.g. 6:50pm
 
     context['posts'] = toplevel.descendants()
     context['tags'] = toplevel.tags()
 
-    context['stylesheets'] = []
-    for media, filenames in CSS[1:]:
-        for filename in [filenames] if isinstance(filenames, basestring) else filenames:
-            stylesheet = {'media': media, 'href': CSS[0] + filename}
-            context['stylesheets'].append(stylesheet)
-
-    context['scripts'] = [JS[0] + filename for filename in JS[1:]]
+    context['stylesheets'] = CSS
+    context['scripts'] = JS
 
     return RequestContext(request, context)