summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris McDonough <chrism@plope.com>2010-11-10 17:04:03 -0500
committerChris McDonough <chrism@plope.com>2010-11-10 17:04:03 -0500
commitfe417289979c168f261f1a887588d5cbf3c3a0fa (patch)
tree671917c978ee75ffad8bbcf97d7da615eb9142cf
parent51c305c772150a8ee8b12c5dbdcb1fc30cb3a251 (diff)
downloadpyramid-fe417289979c168f261f1a887588d5cbf3c3a0fa.tar.gz
pyramid-fe417289979c168f261f1a887588d5cbf3c3a0fa.tar.bz2
pyramid-fe417289979c168f261f1a887588d5cbf3c3a0fa.zip
- New API method: ``pyramid.settings.asbool``.
-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')