Skip to content
Myr

Merge branch '2.7-maintenance'

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Armin Ronacher · committed by Armin Ronacher · parents f6c6fe4, 5662125 · Browse files · 2 files+34 added−3 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+34 added−3 removed

  • other:+34 added−3 removed

2 files+34 added−3 removed

modified:jinja2/bccache.py+28 added-2 removed
13 unmodified lines
14 :copyright: (c) 2010 by the Jinja Team.15 :license: BSD.16"""17from os import path, listdir18import os19import sys20import errno21import marshal22import tempfile23import fnmatch24from hashlib import sha1
165 unmodified lines
190 """A bytecode cache that stores bytecode on the filesystem. It accepts191 two arguments: The directory where the cache items are stored and a192 pattern string that is used to build the filename.193192 If no directory is specified the system temporary items folder is used.194 If no directory is specified a default cache directory is selected. On195 Windows the user's temp directory is used, on UNIX systems a directory196 is created for the user in the system temp directory.197198 The pattern can be used to have multiple separate caches operate on the199 same directory. The default pattern is ``'__jinja2_%s.cache'``. ``%s``200 is replaced with the cache key.
4 unmodified lines
205 """206207 def __init__(self, directory=None, pattern='__jinja2_%s.cache'):208 if directory is None:205 directory = tempfile.gettempdir()209 directory = self._get_default_cache_dir()210 self.directory = directory211 self.pattern = pattern212213 def _get_default_cache_dir(self):214 tmpdir = tempfile.gettempdir()215216 # On windows the temporary directory is used specific unless217 # explicitly forced otherwise. We can just use that.218 if os.name == 'n':219 return tmpdir220 if not hasattr(os, 'getuid'):221 raise RuntimeError('Cannot determine safe temp directory. You '222 'need to explicitly provide one.')223224 dirname = '_jinja2-cache-%d' % os.getuid()225 actual_dir = os.path.join(tmpdir, dirname)226 try:227 # 448 == 0700228 os.mkdir(actual_dir, 448)229 except OSError as e:230 if e.errno != errno.EEXIST:231 raise232233 return actual_dir234235 def _get_cache_filename(self, bucket):236 return path.join(self.directory, self.pattern % bucket.key)237238 def load_bytecode(self, bucket):
99 unmodified lines
modified:CHANGES+6 added-1 removed
10 unmodified lines
11- Added equalto filter that helps with select filters.1213Version 2.7.214-------------15(bugfix release, release date to be decided)15(bugfix release, released on January 10th 2014)1617- Prefix loader was not forwarding the locals properly to18 inner loaders. This is now fixed.19- Security issue: Changed the default folder for the filesystem cache to be20 user specific and read and write protected on UNIX systems. See `Debian bug21 734747`_ for more information.2223.. _Debian bug 734747: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=7347472425Version 2.7.126-------------27(bugfix release, released on August 7th 2013)28
308 unmodified lines