Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: cms/converters.py

Issue 5703725486178304: Issue 2563 - [cms] Cache filters and globals during page generation (Closed)
Patch Set: Created May 20, 2015, 3:51 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: cms/converters.py
===================================================================
--- a/cms/converters.py
+++ b/cms/converters.py
@@ -17,7 +17,6 @@
import os
import HTMLParser
-import imp
import re
import jinja2
@@ -327,7 +326,6 @@
"get_page_content": self.get_page_content,
}
- self._module_refs = []
for dirname, dictionary in [("filters", filters), ("globals", globals)]:
for filename in self._params["source"].list_files(dirname):
root, ext = os.path.splitext(filename)
@@ -335,20 +333,8 @@
continue
path = "%s/%s" % (dirname, filename)
- code = self._params["source"].read_file(path)
- module = imp.new_module(root.replace("/", "."))
- exec code in module.__dict__
-
name = os.path.basename(root)
- if not hasattr(module, name):
- raise Exception("Expected symbol %s not found in %s file %s" % (name, dirname, filename))
- dictionary[name] = getattr(module, name)
-
- # HACK: The module we created here can be garbage collected because it
- # isn't added to sys.modules. If a function is called and its module is
- # gone it might cause weird errors (imports and module variables
- # unavailable). We avoid this situation by keeping a reference.
- self._module_refs.append(module)
+ dictionary[name] = self._params["source"].import_symbol(path, name)
self._env = jinja2.Environment(loader=self._SourceLoader(self._params["source"]), autoescape=True)
self._env.filters.update(filters)
« no previous file with comments | « cms/bin/generate_static_pages.py ('k') | cms/sources.py » ('j') | cms/sources.py » ('J')

Powered by Google App Engine
This is Rietveld