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

Unified Diff: cms/converters.py

Issue 6439782653624320: Issue 2434 - Fixed: Custom filters and global functions can not be instance methods (Closed)
Patch Set: Record module unconditonally Created April 30, 2015, 12:33 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cms/converters.py
===================================================================
--- a/cms/converters.py
+++ b/cms/converters.py
@@ -308,6 +308,7 @@
"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)
@@ -327,11 +328,8 @@
# 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 explicitly referencing the
- # module from the function so they can only be garbage collected
- # together.
- if callable(dictionary[name]):
- dictionary[name].module_ref = module
+ # unavailable). We avoid this situation by keeping a reference.
+ self._module_refs.append(module)
self._env = jinja2.Environment(loader=self._SourceLoader(self._params["source"]), autoescape=True)
self._env.filters.update(filters)
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld