added cache_clear function
Before adoption: this commit came in with the history the project adopted, so no landing records it.
--HG-- branch : trunk
authored by Armin Ronacher · committed by Armin Ronacher · parent aaf010d · Browse files · 5 files·+21 added−4 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
5 files+21 added−4 removed
- other:+21 added−4 removed
Provenance
- Commit
187bde1- Tree
2c03340- Author
Armin Ronacher <armin.ronacher@active-4.com>- Committer
Armin Ronacher <armin.ronacher@active-4.com>- Parent
aaf010d
5 files changed+21 added−4 removed
modified:docs/api.rst+2 added
209 unmodified lines210 Use this if you need to display text that might contain such characters211 in HTML. This function will not escaped objects that do have an HTML212 representation such as already escaped data.213 214+.. autofunction:: jinja2.utils.clear_caches215+216 .. autoclass:: jinja2.utils.Markup217 218 219 Exceptions117 unmodified linesmodified:jinja2/__init__.py+3 added-2 removed
47 unmodified lines48 TemplateNotFound, TemplateSyntaxError, TemplateAssertionError49 50 # decorators and public utilities51 from jinja2.filters import environmentfilter, contextfilter52-from jinja2.utils import Markup, escape, environmentfunction, contextfunction52+from jinja2.utils import Markup, escape, clear_caches, \53+ environmentfunction, contextfunction54 55 __all__ = [56 'Environment', 'Template', 'BaseLoader', 'FileSystemLoader',57 'PackageLoader', 'DictLoader', 'FunctionLoader', 'PrefixLoader',58 'ChoiceLoader', 'Undefined', 'DebugUndefined', 'StrictUndefined',59 'TemplateError', 'UndefinedError', 'TemplateNotFound',60 'TemplateSyntaxError', 'TemplateAssertionError', 'environmentfilter',61 'contextfilter', 'Markup', 'escape', 'environmentfunction',61- 'contextfunction'62+ 'contextfunction', 'clear_caches'63 ]modified:jinja2/debug.py+3 added-1 removed
1 unmodified line2 """3 jinja2.debug4 ~~~~~~~~~~~~5 6- Implements the debug interface for Jinja.6+ Implements the debug interface for Jinja. This module does some pretty7+ ugly stuff with the Python traceback system in order to achieve tracebacks8+ with correct line numbers, locals and contents.9 10 :copyright: Copyright 2008 by Armin Ronacher.11 :license: BSD.12 """179 unmodified linesmodified:jinja2/lexer.py+1 added-1 removed
21 unmodified lines22 23 24 # cache for the lexers. Exists in order to be able to have multiple25 # environments with the same lexer26-_lexer_cache = LRUCache(10)26+_lexer_cache = LRUCache(50)27 28 # static regular expressions29 whitespace_re = re.compile(r'\s+(?um)')30 string_re = re.compile(r"('([^'\\]*(?:\\.[^'\\]*)*)'"403 unmodified linesmodified:jinja2/utils.py+12 added
45 unmodified lines46 f.environmentfunction = True47 return f48 49 50+def clear_caches():51+ """Jinja2 keeps internal caches for environments and lexers. These are52+ used so that Jinja2 doesn't have to recreate environments and lexers all53+ the time. Normally you don't have to care about that but if you are54+ messuring memory consumption you may want to clean the caches.55+ """56+ from jinja2.environment import _spontaneous_environments57+ from jinja2.lexer import _lexer_cache58+ _spontaneous_environments.clear()59+ _lexer_cache.clear()60+61+62 def import_string(import_name, silent=False):63 """Imports an object based on a string. This use useful if you want to64 use import paths as endpoints or something similar. An import path can65 be specified either in dotted notation (``xml.sax.saxutils.escape``)380 unmodified lines