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
Provenance
- Commit
27ffd01- Tree
c497581- Author
Armin Ronacher <armin.ronacher@active-4.com>- Committer
Armin Ronacher <armin.ronacher@active-4.com>- Parent 1
f6c6fe4- Parent 2
5662125
2 files changed+34 added−3 removed
modified:jinja2/bccache.py+28 added-2 removed
13 unmodified lines14 :copyright: (c) 2010 by the Jinja Team.15 :license: BSD.16 """17 from os import path, listdir18+import os19 import sys20+import errno21 import marshal22 import tempfile23 import fnmatch24 from hashlib import sha1165 unmodified lines190 """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.193 192- 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.197 198 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 lines205 """206 207 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 = pattern212 213+ def _get_default_cache_dir(self):214+ tmpdir = tempfile.gettempdir()215+216+ # 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.')223+224+ 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+ raise232+233+ return actual_dir234+235 def _get_cache_filename(self, bucket):236 return path.join(self.directory, self.pattern % bucket.key)237 238 def load_bytecode(self, bucket):99 unmodified linesmodified:CHANGES+6 added-1 removed
10 unmodified lines11 - Added equalto filter that helps with select filters.12 13 Version 2.7.214 -------------15-(bugfix release, release date to be decided)15+(bugfix release, released on January 10th 2014)16 17 - 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.22 23+.. _Debian bug 734747: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=73474724+25 Version 2.7.126 -------------27 (bugfix release, released on August 7th 2013)28 308 unmodified lines