From 388e79e9fcbf689d5708134534e55d176cfbcee3 Mon Sep 17 00:00:00 2001 From: Preston Timmons Date: Wed, 11 Mar 2015 11:00:17 -0500 Subject: Fixed #24493 -- Added BaseContext.setdefault() --- docs/ref/templates/api.txt | 7 +++++++ docs/releases/1.9.txt | 3 +++ 2 files changed, 10 insertions(+) (limited to 'docs') diff --git a/docs/ref/templates/api.txt b/docs/ref/templates/api.txt index 05a6539988..b8e74b75ec 100644 --- a/docs/ref/templates/api.txt +++ b/docs/ref/templates/api.txt @@ -420,6 +420,13 @@ dictionary syntax:: Returns the value for ``key`` if ``key`` is in the context, else returns ``otherwise``. +.. method:: Context.setdefault(key, default=None) + + .. versionadded:: 1.9 + + If ``key`` is in the context, returns its value. Otherwise inserts ``key`` + with a value of ``default`` and returns ``default``. + .. method:: Context.pop() .. method:: Context.push() .. exception:: ContextPopException diff --git a/docs/releases/1.9.txt b/docs/releases/1.9.txt index 08d79cb59a..4375ba2a0d 100644 --- a/docs/releases/1.9.txt +++ b/docs/releases/1.9.txt @@ -166,6 +166,9 @@ Templates helper can now store results in a template variable by using the ``as`` argument. +* Added a :meth:`Context.setdefault() ` + method. + Requests and Responses ^^^^^^^^^^^^^^^^^^^^^^ -- cgit v1.3