[Python-modules-commits] [jinja2] 01/06: Import jinja2_2.9.4.orig.tar.gz

Piotr Ożarowski piotr at moszumanska.debian.org
Tue Jan 10 20:11:20 UTC 2017


This is an automated email from the git hooks/post-receive script.

piotr pushed a commit to branch master
in repository jinja2.

commit 487df3f3e5f434ebb1cfa875576a4c1f2312ea8a
Author: Piotr Ożarowski <piotr at debian.org>
Date:   Tue Jan 10 20:28:37 2017 +0100

    Import jinja2_2.9.4.orig.tar.gz
---
 CHANGES                           |  126 ++++-
 Jinja2.egg-info/PKG-INFO          |    4 +-
 Jinja2.egg-info/SOURCES.txt       |    3 +
 Jinja2.egg-info/requires.txt      |    4 +-
 Makefile                          |    2 +-
 PKG-INFO                          |    4 +-
 README.rst                        |   16 +-
 docs/_templates/sidebarintro.html |    2 +-
 docs/api.rst                      |  151 +++++-
 docs/extensions.rst               |   17 +-
 docs/faq.rst                      |    4 +-
 docs/integration.rst              |   11 +-
 docs/intro.rst                    |    9 +-
 docs/switching.rst                |   31 --
 docs/templates.rst                |   28 +-
 jinja2/__init__.py                |   18 +-
 jinja2/_compat.py                 |   22 +-
 jinja2/asyncfilters.py            |  146 +++++
 jinja2/asyncsupport.py            |  237 +++++++++
 jinja2/bccache.py                 |    4 +-
 jinja2/compiler.py                | 1055 ++++++++++++++++++-------------------
 jinja2/constants.py               |    2 +-
 jinja2/debug.py                   |   42 +-
 jinja2/defaults.py                |   13 +-
 jinja2/environment.py             |  175 ++++--
 jinja2/exceptions.py              |    2 +-
 jinja2/ext.py                     |   35 +-
 jinja2/filters.py                 |  204 ++++---
 jinja2/idtracking.py              |  273 ++++++++++
 jinja2/lexer.py                   |   22 +-
 jinja2/loaders.py                 |    6 +-
 jinja2/meta.py                    |   11 +-
 jinja2/nodes.py                   |   96 ++--
 jinja2/optimizer.py               |   25 +-
 jinja2/parser.py                  |  109 ++--
 jinja2/runtime.py                 |  174 ++++--
 jinja2/sandbox.py                 |  128 ++++-
 jinja2/tests.py                   |   16 +-
 jinja2/utils.py                   |  117 +++-
 jinja2/visitor.py                 |    2 +-
 setup.cfg                         |    7 +-
 setup.py                          |    6 +-
 42 files changed, 2303 insertions(+), 1056 deletions(-)

diff --git a/CHANGES b/CHANGES
index 61cf3a0..f95f41a 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,6 +1,124 @@
 Jinja2 Changelog
 ================
 
+Version 2.9.4
+-------------
+(bugfix release, released on January 10th 2017)
+
+- Solved some warnings for string literals.  (#646)
+- Increment the bytecode cache version which was not done due to an
+  oversight before.
+- Corrected bad code generation and scoping for filtered loops.  (#649)
+- Resolved an issue where top-level output silencing after known extend
+  blocks could generate invalid code when blocks where contained in if
+  statements.  (#651)
+- Made the `truncate.leeway` default configurable to improve compatibility
+  with older templates.
+
+Version 2.9.3
+-------------
+(bugfix release, released on January 8th 2017)
+
+- Restored the use of blocks in macros to the extend that was possible
+  before.  On Python 3 it would render a generator repr instead of
+  the block contents. (#645)
+- Set a consistent behavior for assigning of variables in inner scopes
+  when the variable is also read from an outer scope.  This now sets the
+  intended behavior in all situations however it does not restore the
+  old behavior where limited assignments to outer scopes was possible.
+  For more information and a discussion see #641
+- Resolved an issue where `block scoped` would not take advantage of the
+  new scoping rules.  In some more exotic cases a variable overriden in a
+  local scope would not make it into a block.
+- Change the code generation of the `with` statement to be in line with the
+  new scoping rules.  This resolves some unlikely bugs in edge cases.  This
+  also introduces a new internal `With` node that can be used by extensions.
+
+Version 2.9.2
+-------------
+(bugfix release, released on January 8th 2017)
+
+- Fixed a regression that caused for loops to not be able to use the same
+  variable for the target as well as source iterator.  (#640)
+- Add support for a previously unknown behavior of macros.  It used to be
+  possible in some circumstances to explicitly provide a caller argument
+  to macros.  While badly buggy and unintended it turns out that this is a
+  common case that gets copy pasted around.  To not completely break backwards
+  compatibility with the most common cases it's now possible to provide an
+  explicit keyword argument for caller if it's given an explicit default.
+  (#642)
+
+Version 2.9.1
+-------------
+(bugfix release, released on January 7th 2017)
+
+- Resolved a regression with call block scoping for macros.  Nested caller
+  blocks that used the same identifiers as outer macros could refer to the
+  wrong variable incorrectly.
+
+Version 2.9
+-----------
+(codename Derivation, released on January 7th 2017)
+
+- Change cache key definition in environment. This fixes a performance
+  regression introduced in 2.8.
+- Added support for `generator_stop` on supported Python versions
+  (Python 3.5 and later)
+- Corrected a long standing issue with operator precedence of math operations
+  not being what was expected.
+- Added support for Python 3.6 async iterators through a new async mode.
+- Added policies for filter defaults and similar things.
+- urlize now sets "rel noopener" by default.
+- Support attribute fallback for old-style classes in 2.x.
+- Support toplevel set statements in extend situations.
+- Restored behavior of Cycler for Python 3 users.
+- Subtraction now follows the same behavior as other operators on undefined
+  values.
+- `map` and friends will now give better error messages if you forgot to
+  quote the parameter.
+- Depend on MarkupSafe 0.23 or higher.
+- Improved the `truncate` filter to support better truncation in case
+  the string is barely truncated at all.
+- Change the logic for macro autoescaping to be based on the runtime
+  autoescaping information at call time instead of macro define time.
+- Ported a modified version of the `tojson` filter from Flask to Jinja2
+  and hooked it up with the new policy framework.
+- Block sets are now marked `safe` by default.
+- On Python 2 the asciification of ASCII strings can now be disabled with
+  the `compiler.ascii_str` policy.
+- Tests now no longer accept an arbitrary expression as first argument but
+  a restricted one.  This means that you can now properly use multiple
+  tests in one expression without extra parentheses.  In particular you can
+  now write ``foo is divisibleby 2 or foo is divisibleby 3``
+  as you would expect.
+- Greatly changed the scoping system to be more consistent with what template
+  designers and developers expect.  There is now no more magic difference
+  between the different include and import constructs.  Context is now always
+  propagated the same way.  The only remaining differences is the defaults
+  for `with context` and `without context`.
+- The `with` and `autoescape` tags are now built-in.
+- Added the new `select_autoescape` function which helps configuring better
+  autoescaping easier.
+
+Version 2.8.2
+-------------
+
+(bugfix release, unreleased)
+
+- Fixed a runtime error in the sandbox when attributes of async generators
+  were accessed.
+
+Version 2.8.1
+-------------
+
+(bugfix release, released on December 29th 2016)
+
+- Fixed the `for_qs` flag for `urlencode`.
+- Fixed regression when applying `int` to non-string values.
+- SECURITY: if the sandbox mode is used format expressions are now sandboxed
+  with the same rules as in Jinja.  This solves various information leakage
+  problems that can occur with format strings.
+
 Version 2.8
 -----------
 (codename Replacement, released on July 26th 2015)
@@ -19,7 +137,7 @@ Version 2.8
 - If unmarshalling of cached data fails the template will be
   reloaded now.
 - Implemented a block ``set`` tag.
-- Default cache size was incrased to 400 from a low 50.
+- Default cache size was increased to 400 from a low 50.
 - Fixed ``is number`` test to accept long integers in all Python versions.
 - Changed ``is number`` to accept Decimal as a number.
 - Added a check for default arguments followed by non-default arguments. This
@@ -125,7 +243,7 @@ Version 2.6
   makes this necessary, Jinja2 will automatically detect these cases now.
 - the sum filter can now sum up values by attribute.  This is a backwards
   incompatible change.  The argument to the filter previously was the
-  optional starting index which defaultes to zero.  This now became the
+  optional starting index which defaults to zero.  This now became the
   second argument to the function because it's rarely used.
 - like sum, sort now also makes it possible to order items by attribute.
 - like sum and sort, join now also is able to join attributes of objects
@@ -183,11 +301,11 @@ Version 2.5.1
   pulled from markupsafe by the Jinja2 developers.  The debug support
   went into a separate feature called "debugsupport" and is disabled
   by default because it is only relevant for Python 2.4
-- fixed an issue with unary operators having the wrong precendence.
+- fixed an issue with unary operators having the wrong precedence.
 
 Version 2.5
 -----------
-(codename Incoherence, relased on May 29th 2010)
+(codename Incoherence, released on May 29th 2010)
 
 - improved the sort filter (should have worked like this for a
   long time) by adding support for case insensitive searches.
diff --git a/Jinja2.egg-info/PKG-INFO b/Jinja2.egg-info/PKG-INFO
index b410730..02ba56e 100644
--- a/Jinja2.egg-info/PKG-INFO
+++ b/Jinja2.egg-info/PKG-INFO
@@ -1,6 +1,6 @@
 Metadata-Version: 1.1
 Name: Jinja2
-Version: 2.8
+Version: 2.9.4
 Summary: A small but fast and easy to use stand-alone template engine written in pure python.
 Home-page: http://jinja.pocoo.org/
 Author: Armin Ronacher
@@ -54,6 +54,8 @@ Classifier: Programming Language :: Python :: 2.6
 Classifier: Programming Language :: Python :: 2.7
 Classifier: Programming Language :: Python :: 3
 Classifier: Programming Language :: Python :: 3.3
+Classifier: Programming Language :: Python :: 3.4
+Classifier: Programming Language :: Python :: 3.5
 Classifier: Topic :: Internet :: WWW/HTTP :: Dynamic Content
 Classifier: Topic :: Software Development :: Libraries :: Python Modules
 Classifier: Topic :: Text Processing :: Markup :: HTML
diff --git a/Jinja2.egg-info/SOURCES.txt b/Jinja2.egg-info/SOURCES.txt
index 0b78a6d..e6bafaa 100644
--- a/Jinja2.egg-info/SOURCES.txt
+++ b/Jinja2.egg-info/SOURCES.txt
@@ -84,6 +84,8 @@ ext/django2jinja/templates/subtemplate.html
 jinja2/__init__.py
 jinja2/_compat.py
 jinja2/_stringdefs.py
+jinja2/asyncfilters.py
+jinja2/asyncsupport.py
 jinja2/bccache.py
 jinja2/compiler.py
 jinja2/constants.py
@@ -93,6 +95,7 @@ jinja2/environment.py
 jinja2/exceptions.py
 jinja2/ext.py
 jinja2/filters.py
+jinja2/idtracking.py
 jinja2/lexer.py
 jinja2/loaders.py
 jinja2/meta.py
diff --git a/Jinja2.egg-info/requires.txt b/Jinja2.egg-info/requires.txt
index 8427b61..1d74a32 100644
--- a/Jinja2.egg-info/requires.txt
+++ b/Jinja2.egg-info/requires.txt
@@ -1,4 +1,4 @@
-MarkupSafe
+MarkupSafe>=0.23
 
 [i18n]
-Babel>=0.8
\ No newline at end of file
+Babel>=0.8
diff --git a/Makefile b/Makefile
index aadaaa9..3c12a8c 100644
--- a/Makefile
+++ b/Makefile
@@ -1,5 +1,5 @@
 test:
-	py.test
+	py.test tests --tb=short
 
 develop:
 	pip install --editable .
diff --git a/PKG-INFO b/PKG-INFO
index b410730..02ba56e 100644
--- a/PKG-INFO
+++ b/PKG-INFO
@@ -1,6 +1,6 @@
 Metadata-Version: 1.1
 Name: Jinja2
-Version: 2.8
+Version: 2.9.4
 Summary: A small but fast and easy to use stand-alone template engine written in pure python.
 Home-page: http://jinja.pocoo.org/
 Author: Armin Ronacher
@@ -54,6 +54,8 @@ Classifier: Programming Language :: Python :: 2.6
 Classifier: Programming Language :: Python :: 2.7
 Classifier: Programming Language :: Python :: 3
 Classifier: Programming Language :: Python :: 3.3
+Classifier: Programming Language :: Python :: 3.4
+Classifier: Programming Language :: Python :: 3.5
 Classifier: Topic :: Internet :: WWW/HTTP :: Dynamic Content
 Classifier: Topic :: Software Development :: Libraries :: Python Modules
 Classifier: Topic :: Text Processing :: Markup :: HTML
diff --git a/README.rst b/README.rst
index 0684e8a..c36b942 100644
--- a/README.rst
+++ b/README.rst
@@ -8,7 +8,9 @@ an optional `sandboxed`_ environment.
 Nutshell
 --------
 
-Here a small example of a Jinja template::
+Here a small example of a Jinja template:
+
+.. code-block:: jinja
 
     {% extends 'base.html' %}
     {% block title %}Memberlist{% endblock %}
@@ -28,8 +30,8 @@ life difficult by restricting functionality too much.
 
 For more information visit the new `Jinja2 webpage`_ and `documentation`_.
 
-The `Jinja2 tip`_ is installable via `easy_install` with ``easy_install
-Jinja2==dev``.
+The `Jinja2 tip`_ is installable via ``pip`` with ``pip install
+https://github.com/pallets/jinja/zipball/master``.
 
 .. _sandboxed: http://en.wikipedia.org/wiki/Sandbox_(computer_security)
 .. _Django: http://www.djangoproject.com/
@@ -41,9 +43,9 @@ Builds
 ------
 
 +---------------------+------------------------------------------------------------------------------+
-| ``master``          | .. image:: https://travis-ci.org/mitsuhiko/jinja2.svg?branch=master          |
-|                     |     :target: https://travis-ci.org/mitsuhiko/jinja2                          |
+| ``master``          | .. image:: https://travis-ci.org/pallets/jinja.svg?branch=master             |
+|                     |     :target: https://travis-ci.org/pallets/jinja                             |
 +---------------------+------------------------------------------------------------------------------+
-| ``2.7-maintenance`` | .. image:: https://travis-ci.org/mitsuhiko/jinja2.svg?branch=2.7-maintenance |
-|                     |     :target: https://travis-ci.org/mitsuhiko/jinja2                          |
+| ``2.9-maintenance`` | .. image:: https://travis-ci.org/pallets/jinja.svg?branch=2.9-maintenance    |
+|                     |     :target: https://travis-ci.org/pallets/jinja                             |
 +---------------------+------------------------------------------------------------------------------+
diff --git a/docs/_templates/sidebarintro.html b/docs/_templates/sidebarintro.html
index b7fcfda..9c430c0 100644
--- a/docs/_templates/sidebarintro.html
+++ b/docs/_templates/sidebarintro.html
@@ -16,5 +16,5 @@
 <ul>
   <li><a href="http://jinja.pocoo.org/">The Jinja2 Website</a></li>
   <li><a href="http://pypi.python.org/pypi/Jinja2">Jinja2 @ PyPI</a></li>
-  <li><a href="http://github.com/mitsuhiko/jinja2">Jinja2 @ github</a></li>
+  <li><a href="http://github.com/pallets/jinja">Jinja2 @ github</a></li>
 </ul>
diff --git a/docs/api.rst b/docs/api.rst
index 088c867..443d053 100644
--- a/docs/api.rst
+++ b/docs/api.rst
@@ -19,21 +19,25 @@ Even if you are creating templates from strings by using the constructor of
 albeit a shared one.
 
 Most applications will create one :class:`Environment` object on application
-initialization and use that to load templates.  In some cases it's however
+initialization and use that to load templates.  In some cases however, it's 
 useful to have multiple environments side by side, if different configurations
 are in use.
 
 The simplest way to configure Jinja2 to load templates for your application
 looks roughly like this::
 
-    from jinja2 import Environment, PackageLoader
-    env = Environment(loader=PackageLoader('yourapplication', 'templates'))
+    from jinja2 import Environment, PackageLoader, select_autoescape
+    env = Environment(
+        loader=PackageLoader('yourapplication', 'templates'),
+        autoescape=select_autoescape(['html', 'xml'])
+    )
 
 This will create a template environment with the default settings and a
 loader that looks up the templates in the `templates` folder inside the
 `yourapplication` python package.  Different loaders are available
 and you can also write your own if you want to load templates from a
-database or other resources.
+database or other resources.  This also enables autoescaping for HTML and
+XML files.
 
 To load a template from this environment you just have to call the
 :meth:`get_template` method which then returns the loaded :class:`Template`::
@@ -48,6 +52,12 @@ Using a template loader rather than passing strings to :class:`Template`
 or :meth:`Environment.from_string` has multiple advantages.  Besides being
 a lot easier to use it also enables template inheritance.
 
+.. admonition:: Notes on Autoescaping
+
+   In future versions of Jinja2 we might enable autoescaping by default
+   for security reasons.  As such you are encouraged to explicitly
+   configure autoescaping now instead of relying on the default.
+
 
 Unicode
 -------
@@ -154,6 +164,12 @@ useful if you want to dig deeper into Jinja2 or :ref:`develop extensions
         to modify this dict.  For more details see :ref:`global-namespace`.
         For valid object names have a look at :ref:`identifier-naming`.
 
+    .. attribute:: policies
+
+        A dictionary with :ref:`policies`.  These can be reconfigured to
+        change the runtime behavior or certain template features.  Usually
+        these are security related.
+
     .. attribute:: code_generator_class
 
        The class used for code generation.  This should not be changed
@@ -229,6 +245,10 @@ useful if you want to dig deeper into Jinja2 or :ref:`develop extensions
 
     .. automethod:: stream([context])
 
+    .. automethod:: render_async([context])
+
+    .. automethod:: generate_async([context])
+
 
 .. autoclass:: jinja2.environment.TemplateStream()
     :members: disable_buffering, enable_buffering, dump
@@ -237,30 +257,38 @@ useful if you want to dig deeper into Jinja2 or :ref:`develop extensions
 Autoescaping
 ------------
 
-.. versionadded:: 2.4
+.. versionchanged:: 2.4
 
-As of Jinja 2.4 the preferred way to do autoescaping is to enable the
-:ref:`autoescape-extension` and to configure a sensible default for
+Jinja2 now comes with autoescaping support.  As of Jinja 2.9 the
+autoescape extension is removed and built-in.  However autoescaping is
+not yet enabled by default though this will most likely change in the
+future.  It's recommended to configure a sensible default for
 autoescaping.  This makes it possible to enable and disable autoescaping
 on a per-template basis (HTML versus text for instance).
 
+.. autofunction:: jinja2.select_autoescape
+
 Here a recommended setup that enables autoescaping for templates ending
 in ``'.html'``, ``'.htm'`` and ``'.xml'`` and disabling it by default
-for all other extensions::
+for all other extensions.  You can use the :func:`~jinja2.select_autoescape`
+function for this::
 
-    def guess_autoescape(template_name):
-        if template_name is None or '.' not in template_name:
-            return False
-        ext = template_name.rsplit('.', 1)[1]
-        return ext in ('html', 'htm', 'xml')
+    from jinja2 import Environment, select_autoescape
+    env = Environment(autoescape=select_autoescape(['html', 'htm', 'xml']),
+                      loader=PackageLoader('mypackage'))
+
+The :func:`~jinja.select_autoescape` function returns a function that
+works rougly like this::
 
-    env = Environment(autoescape=guess_autoescape,
-                      loader=PackageLoader('mypackage'),
-                      extensions=['jinja2.ext.autoescape'])
+    def autoescape(template_name):
+        if template_name is None:
+            return False
+        if template_name.endswith(('.html', '.htm', '.xml'))
 
 When implementing a guessing autoescape function, make sure you also
 accept `None` as valid template name.  This will be passed when generating
-templates from strings.
+templates from strings.  You should always configure autoescaping as
+defaults in the future might change.
 
 Inside the templates the behaviour can be temporarily changed by using
 the `autoescape` block (see :ref:`autoescape-overrides`).
@@ -497,6 +525,93 @@ Builtin bytecode caches:
 .. autoclass:: jinja2.MemcachedBytecodeCache
 
 
+Async Support
+-------------
+
+Starting with version 2.9, Jinja2 also supports the Python `async` and
+`await` constructs.  As far as template designers go this feature is
+entirely opaque to them however as a developer you should be aware of how
+it's implemented as it influences what type of APIs you can safely expose
+to the template environment.
+
+First you need to be aware that by default async support is disabled as
+enabling it will generate different template code behind the scenes which
+passes everything through the asyncio event loop.  This is important to
+understand because it has some impact to what you are doing:
+
+*   template rendering will require an event loop to be set for the
+    current thread (``asyncio.get_event_loop`` needs to return one)
+*   all template generation code internally runs async generators which
+    means that you will pay a performance penalty even if the non sync
+    methods are used!
+*   The sync methods are based on async methods if the async mode is
+    enabled which means that `render` for instance will internally invoke
+    `render_async` and run it as part of the current event loop until the
+    execution finished.
+
+Awaitable objects can be returned from functions in templates and any
+function call in a template will automatically await the result.  This
+means that you can let provide a method that asynchronously loads data
+from a database if you so desire and from the template designer's point of
+view this is just another function they can call.  This means that the
+``await`` you would normally issue in Python is implied.  However this
+only applies to function calls.  If an attribute for instance would be an
+avaitable object then this would not result in the expected behavior.
+
+Likewise iterations with a `for` loop support async iterators.
+
+.. _policies:
+
+Policies
+--------
+
+Starting with Jinja 2.9 policies can be configured on the environment
+which can slightly influence how filters and other template constructs
+behave.  They can be configured with the
+:attr:`~jinja2.Environment.policies` attribute.
+
+Example::
+
+    env.policies['urlize.rel'] = 'nofollow noopener'
+
+``compiler.ascii_str``:
+    This boolean controls on Python 2 if Jinja2 should store ASCII only
+    literals as bytestring instead of unicode strings.  This used to be
+    always enabled for Jinja versions below 2.9 and now can be changed.
+    Traditionally it was done this way since some APIs in Python 2 failed
+    badly for unicode strings (for instance the datetime strftime API).
+    Now however sometimes the inverse is true (for instance str.format).
+    If this is set to False then all strings are stored as unicode
+    internally.
+
+``truncate.leeway``:
+    Configures the leeway default for the `truncate` filter.  Leeway as
+    introduced in 2.9 but to restore compatibility with older templates
+    it can be configured to `0` to get the old behavior back.  The default
+    is `5`.
+
+``urlize.rel``:
+    A string that defines the items for the `rel` attribute of generated
+    links with the `urlize` filter.  These items are always added.  The
+    default is `noopener`.
+
+``urlize.target``:
+    The default target that is issued for links from the `urlize` filter
+    if no other target is defined by the call explicitly.
+
+``json.dumps_function``:
+    If this is set to a value other than `None` then the `tojson` filter
+    will dump with this function instead of the default one.  Note that
+    this function should accept arbitrary extra arguments which might be
+    passed in the future from the filter.  Currently the only argument
+    that might be passed is `indent`.  The default dump function is
+    ``json.dumps``.
+
+``json.dumps_kwargs``:
+    Keyword arguments to be passed to the dump function.  The default is
+    ``{'sort_keys': True}``.
+
+
 Utilities
 ---------
 
@@ -581,7 +696,7 @@ Custom Filters
 --------------
 
 Custom filters are just regular Python functions that take the left side of
-the filter as first argument and the the arguments passed to the filter as
+the filter as first argument and the arguments passed to the filter as
 extra arguments or keyword arguments.
 
 For example in the filter ``{{ 42|myfilter(23) }}`` the function would be
diff --git a/docs/extensions.rst b/docs/extensions.rst
index 0825fd4..635d1e4 100644
--- a/docs/extensions.rst
+++ b/docs/extensions.rst
@@ -107,7 +107,7 @@ The usage of the `i18n` extension for template designers is covered as part
 :ref:`of the template documentation <i18n-in-templates>`.
 
 .. _gettext: http://docs.python.org/dev/library/gettext
-.. _Babel: http://babel.edgewall.org/
+.. _Babel: http://babel.pocoo.org/
 
 .. _newstyle-gettext:
 
@@ -183,12 +183,9 @@ With Statement
 
 **Import name:** `jinja2.ext.with_`
 
-.. versionadded:: 2.3
+.. versionchanged:: 2.9
 
-This extension adds support for the with keyword.  Using this keyword it
-is possible to enforce a nested scope in a template.  Variables can be
-declared directly in the opening block of the with statement or using a
-standard `set` statement directly within.
+This extension is now built-in and no longer does anything.
 
 .. _autoescape-extension:
 
@@ -197,12 +194,10 @@ Autoescape Extension
 
 **Import name:** `jinja2.ext.autoescape`
 
-.. versionadded:: 2.4
+.. versionchanged:: 2.9
 
-The autoescape extension allows you to toggle the autoescape feature from
-within the template.  If the environment's :attr:`~Environment.autoescape`
-setting is set to `False` it can be activated, if it's `True` it can be
-deactivated.  The setting overriding is scoped.
+This extension was removed and is now built-in.  Enabling the extension
+no longer does anything.
 
 
 .. _writing-extensions:
diff --git a/docs/faq.rst b/docs/faq.rst
index 0b0375e..9dd348f 100644
--- a/docs/faq.rst
+++ b/docs/faq.rst
@@ -141,8 +141,8 @@ work in production environments::
 
     import os
     if os.environ.get('SERVER_SOFTWARE', '').startswith('Dev'):
-        from google.appengine.tools.dev_appserver import HardenedModulesHook
-        HardenedModulesHook._WHITE_LIST_C_MODULES += ['_ctypes', 'gestalt']
+        from google.appengine.tools.devappserver2.python import sandbox
+        sandbox._WHITE_LIST_C_MODULES += ['_ctypes', 'gestalt']
 
 Credit for this snippet goes to `Thomas Johansson
 <http://stackoverflow.com/questions/3086091/debug-jinja2-in-google-app-engine/3694434#3694434>`_
diff --git a/docs/integration.rst b/docs/integration.rst
index 79dff76..3a4988b 100644
--- a/docs/integration.rst
+++ b/docs/integration.rst
@@ -6,7 +6,7 @@ the `Babel`_ library or your favourite editor for fancy code highlighting.
 This is a brief description of whats included.
 
 Files to help integration are available
-`here. <https://github.com/mitsuhiko/jinja2/tree/master/ext>`_
+`here. <https://github.com/pallets/jinja/tree/master/ext>`_
 
 .. _babel-integration:
 
@@ -50,7 +50,7 @@ automatically.
    want that behavior you can add ``silent=false`` to the settings and
    exceptions are propagated.
 
-.. _mapping file: http://babel.edgewall.org/wiki/Documentation/messages.html#extraction-method-mapping-and-configuration
+.. _mapping file: http://babel.pocoo.org/en/latest/messages.html#extraction-method-mapping-and-configuration
 
 Pylons
 ------
@@ -81,10 +81,11 @@ snippet and add it into your `config/environment.py`::
 TextMate
 --------
 
-Inside the `ext` folder at the root of the Jinja2 project there is a bundle for
-TextMate that supports syntax highlighting for Jinja1 and Jinja2 for text based
+There is a `bundle for TextMate`_ that supports syntax highlighting for Jinja1 and Jinja2 for text based
 templates as well as HTML.  It also contains a few often used snippets.
 
+.. _bundle for TextMate: https://github.com/mitsuhiko/jinja2-tmbundle
+
 Vim
 ---
 
@@ -96,5 +97,5 @@ The first one for text based templates, the latter for HTML templates.
 
 Copy the files into your `syntax` folder.
 
-.. _Babel: http://babel.edgewall.org/
+.. _Babel: http://babel.pocoo.org/
 .. _Vim: http://www.vim.org/
diff --git a/docs/intro.rst b/docs/intro.rst
index 99c3582..e097718 100644
--- a/docs/intro.rst
+++ b/docs/intro.rst
@@ -36,15 +36,12 @@ You can install the most recent Jinja2 version using `easy_install`_ or `pip`_::
 This will install a Jinja2 egg in your Python installation's site-packages
 directory.
 
-(If you are installing from the Windows command line omit the `sudo` and make
-sure to run the command as user with administrator rights)
-
 From the tarball release
 ~~~~~~~~~~~~~~~~~~~~~~~~~
 
 1.  Download the most recent tarball from the `download page`_
 2.  Unpack the tarball
-3.  ``sudo python setup.py install``
+3.  ``python setup.py install``
 
 Note that you either have to have `setuptools` or `distribute` installed;
 the latter is preferred.
@@ -55,7 +52,7 @@ Installing the development version
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
 1.  Install `git`_
-2.  ``git clone git://github.com/mitsuhiko/jinja2.git``
+2.  ``git clone git://github.com/pallets/jinja.git``
 3.  ``cd jinja2``
 4.  ``ln -s jinja2 /usr/lib/python2.X/site-packages``
 
@@ -120,4 +117,4 @@ in mind, so you will have to adapt the shown code examples to Python 3 syntax
 for yourself.
 
 
-.. _Jinja bug tracker: http://github.com/mitsuhiko/jinja2/issues
+.. _Jinja bug tracker: http://github.com/pallets/jinja/issues
diff --git a/docs/switching.rst b/docs/switching.rst
index ab94124..01a7d0d 100644
--- a/docs/switching.rst
+++ b/docs/switching.rst
@@ -116,37 +116,6 @@ Python syntax. Thus this Django code::
 This allows you to pass variables to the method, which is not possible in
 Django. This syntax is also used for macros.
 
-Conditions
-~~~~~~~~~~
-
-In Django you can use the following constructs to check for equality::
-
-    {% ifequal foo "bar" %}
-        ...
-    {% else %}
-        ...
-    {% endifequal %}
-
-In Jinja2 you can use the normal if statement in combination with operators::
-
-    {% if foo == 'bar' %}
-        ...
-    {% else %}
-        ...
-    {% endif %}
-
-You can also have multiple elif branches in your template::
-
-    {% if something %}
-        ...
-    {% elif otherthing %}
-        ...
-    {% elif foothing %}
-        ...
-    {% else %}
-        ...
-    {% endif %}
-
 Filter Arguments
 ~~~~~~~~~~~~~~~~
 
diff --git a/docs/templates.rst b/docs/templates.rst
index d9102ec..48f1894 100644
--- a/docs/templates.rst
+++ b/docs/templates.rst
@@ -606,10 +606,10 @@ Inside of a for-loop block, you can access some special variables:
 | `loop.cycle`          | A helper function to cycle between a list of      |
 |                       | sequences.  See the explanation below.            |
 +-----------------------+---------------------------------------------------+
-| `loop.depth`          | Indicates how deep in deep in a recursive loop    |
+| `loop.depth`          | Indicates how deep in a recursive loop            |
 |                       | the rendering currently is.  Starts at level 1    |
 +-----------------------+---------------------------------------------------+
-| `loop.depth0`         | Indicates how deep in deep in a recursive loop    |
+| `loop.depth0`         | Indicates how deep in a recursive loop            |
 |                       | the rendering currently is.  Starts at level 0    |
 +-----------------------+---------------------------------------------------+
 
@@ -681,7 +681,7 @@ If
 
 The `if` statement in Jinja is comparable with the Python if statement.
 In the simplest form, you can use it to test if a variable is defined, not
-empty or not false::
+empty and not false::
 
     {% if users %}
     <ul>
@@ -1460,10 +1460,8 @@ With Statement
 
 .. versionadded:: 2.3
 
-If the application enables the :ref:`with-extension`, it is possible to
-use the `with` keyword in templates.  This makes it possible to create
-a new inner scope.  Variables set within this scope are not visible
-outside of the scope.
+The with statement makes it possible to create a new inner scope.
+Variables set within this scope are not visible outside of the scope.
 
 With in a nutshell::
 
@@ -1486,15 +1484,20 @@ are equivalent::
         {{ foo }}
     {% endwith %}
 
+.. admonition:: Extension
+
+   In older versions of Jinja (before 2.9) it was required to enable this
+   feature with an extension.  It's now enabled by default.
+
 .. _autoescape-overrides:
 
-Autoescape Extension
+Autoescape Overrides
 --------------------
 
 .. versionadded:: 2.4
 
-If the application enables the :ref:`autoescape-extension`, one can
-activate and deactivate the autoescaping from within the templates.
+If you want you can activate and deactivate the autoescaping from within
+the templates.
 
 Example::
 
@@ -1507,3 +1510,8 @@ Example::
     {% endautoescape %}
 
 After an `endautoescape` the behavior is reverted to what it was before.
+
+.. admonition:: Extension
+
+   In older versions of Jinja (before 2.9) it was required to enable this
+   feature with an extension.  It's now enabled by default.
diff --git a/jinja2/__init__.py b/jinja2/__init__.py
index 029fb2e..360b54f 100644
--- a/jinja2/__init__.py
+++ b/jinja2/__init__.py
@@ -23,11 +23,11 @@
         {% endblock %}
 
 
-    :copyright: (c) 2010 by the Jinja Team.
+    :copyright: (c) 2017 by the Jinja Team.
     :license: BSD, see LICENSE for more details.
 """
 __docformat__ = 'restructuredtext en'
-__version__ = '2.8'
+__version__ = '2.9.4'
 
 # high level interface
 from jinja2.environment import Environment, Template
@@ -55,7 +55,7 @@ from jinja2.filters import environmentfilter, contextfilter, \
      evalcontextfilter
 from jinja2.utils import Markup, escape, clear_caches, \
      environmentfunction, evalcontextfunction, contextfunction, \
-     is_undefined
+     is_undefined, select_autoescape
 
 __all__ = [
     'Environment', 'Template', 'BaseLoader', 'FileSystemLoader',
@@ -67,4 +67,16 @@ __all__ = [
     'ModuleLoader', 'environmentfilter', 'contextfilter', 'Markup', 'escape',
     'environmentfunction', 'contextfunction', 'clear_caches', 'is_undefined',
     'evalcontextfilter', 'evalcontextfunction', 'make_logging_undefined',
+    'select_autoescape',
 ]
+
+
+def _patch_async():
+    from jinja2.utils import have_async_gen
+    if have_async_gen:
+        from jinja2.asyncsupport import patch_all
+        patch_all()
+
+
+_patch_async()
+del _patch_async
diff --git a/jinja2/_compat.py b/jinja2/_compat.py
index 143962f..61d8530 100644
--- a/jinja2/_compat.py
+++ b/jinja2/_compat.py
@@ -45,7 +45,6 @@ if not PY2:
     implements_iterator = _identity
     implements_to_string = _identity
     encode_filename = _identity
-    get_next = lambda x: x.__next__
 
 else:
     unichr = unichr
@@ -77,8 +76,6 @@ else:
         cls.__str__ = lambda x: x.__unicode__().encode('utf-8')
         return cls
 
-    get_next = lambda x: x.next
-
     def encode_filename(filename):
         if isinstance(filename, unicode):
             return filename.encode('utf-8')
@@ -86,23 +83,14 @@ else:
 
 
 def with_metaclass(meta, *bases):
+    """Create a base class with a metaclass."""
     # This requires a bit of explanation: the basic idea is to make a
-    # dummy metaclass for one level of class instanciation that replaces
-    # itself with the actual metaclass.  Because of internal type checks
-    # we also need to make sure that we downgrade the custom metaclass
-    # for one level to something closer to type (that's why __call__ and
-    # __init__ comes back from type etc.).
-    #
-    # This has the advantage over six.with_metaclass in that it does not
-    # introduce dummy classes into the final MRO.
-    class metaclass(meta):
-        __call__ = type.__call__
-        __init__ = type.__init__
+    # dummy metaclass for one level of class instantiation that replaces
+    # itself with the actual metaclass.
+    class metaclass(type):
         def __new__(cls, name, this_bases, d):
-            if this_bases is None:
-                return type.__new__(cls, name, (), d)
             return meta(name, bases, d)
-    return metaclass('temporary_class', None, {})
+    return type.__new__(metaclass, 'temporary_class', (), {})
 
 
 try:
diff --git a/jinja2/asyncfilters.py b/jinja2/asyncfilters.py
new file mode 100644
index 0000000..5c1f46d
--- /dev/null
+++ b/jinja2/asyncfilters.py
@@ -0,0 +1,146 @@
+from functools import wraps
+
+from jinja2.asyncsupport import auto_aiter
+from jinja2 import filters
+
+
+async def auto_to_seq(value):
+    seq = []
+    if hasattr(value, '__aiter__'):
+        async for item in value:
+            seq.append(item)
+    else:
+        for item in value:
+            seq.append(item)
+    return seq
+
+
+async def async_select_or_reject(args, kwargs, modfunc, lookup_attr):
+    seq, func = filters.prepare_select_or_reject(
+        args, kwargs, modfunc, lookup_attr)
+    if seq:
+        async for item in auto_aiter(seq):
+            if func(item):
+                yield item
+
+
+def dualfilter(normal_filter, async_filter):
+    wrap_evalctx = False
+    if getattr(normal_filter, 'environmentfilter', False):
+        is_async = lambda args: args[0].is_async
+        wrap_evalctx = False
+    else:
+        if not getattr(normal_filter, 'evalcontextfilter', False) and \
+           not getattr(normal_filter, 'contextfilter', False):
+            wrap_evalctx = True
+        is_async = lambda args: args[0].environment.is_async
+
+    @wraps(normal_filter)
+    def wrapper(*args, **kwargs):
+        b = is_async(args)
+        if wrap_evalctx:
+            args = args[1:]
+        if b:
+            return async_filter(*args, **kwargs)
+        return normal_filter(*args, **kwargs)
+
+    if wrap_evalctx:
+        wrapper.evalcontextfilter = True
+
+    wrapper.asyncfiltervariant = True
+
+    return wrapper
+
+
+def asyncfiltervariant(original):
+    def decorator(f):
+        return dualfilter(original, f)
+    return decorator
+
+
+ at asyncfiltervariant(filters.do_first)
+async def do_first(environment, seq):
+    try:
+        return await auto_aiter(seq).__anext__()
+    except StopAsyncIteration:
+        return environment.undefined('No first item, sequence was empty.')
+
+
+ at asyncfiltervariant(filters.do_groupby)
+async def do_groupby(environment, value, attribute):
+    expr = filters.make_attrgetter(environment, attribute)
+    return [filters._GroupTuple(key, await auto_to_seq(values))
+            for key, values in filters.groupby(sorted(
+                await auto_to_seq(value), key=expr), expr)]
... 4498 lines suppressed ...

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/jinja2.git



More information about the Python-modules-commits mailing list