summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGES.txt2
-rw-r--r--docs/api/settings.rst3
-rw-r--r--pyramid/settings.py3
3 files changed, 8 insertions, 0 deletions
diff --git a/CHANGES.txt b/CHANGES.txt
index 6bfb47054..15819b257 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -11,6 +11,8 @@ Features
- Added class vars ``matchdict`` and ``matched_route`` to
``pyramid.request.Request``. Each is set to ``None``.
+- New API method: ``pyramid.settings.asbool``.
+
Bug Fixes
---------
diff --git a/docs/api/settings.rst b/docs/api/settings.rst
index acd674f66..ac1cd3f9c 100644
--- a/docs/api/settings.rst
+++ b/docs/api/settings.rst
@@ -7,3 +7,6 @@
.. autofunction:: get_settings
+ .. autofunction:: asbool
+
+
diff --git a/pyramid/settings.py b/pyramid/settings.py
index d4e54a38e..cdf0b177f 100644
--- a/pyramid/settings.py
+++ b/pyramid/settings.py
@@ -80,6 +80,9 @@ def get_settings():
return reg.queryUtility(ISettings)
def asbool(s):
+ """ Return the boolean value ``True`` if the case-lowered value of string
+ input ``s`` is any of ``t``, ``true``, ``y``, ``on``, or ``1``, otherwise
+ return the boolean value ``False``."""
s = str(s).strip()
return s.lower() in ('t', 'true', 'y', 'yes', 'on', '1')