diff --git a/src/milla/app.py b/src/milla/app.py index 2a54876..7b22451 100644 --- a/src/milla/app.py +++ b/src/milla/app.py @@ -8,6 +8,7 @@ Please give me a docstring! :Updater: $Author$ ''' from milla.controllers import FaviconController +from milla.util import asbool from webob.exc import HTTPNotFound, WSGIHTTPException import milla.dispatch import webob @@ -42,17 +43,6 @@ class Application(object): try: func = self.dispatcher.resolve(path_info) except milla.dispatch.UnresolvedPath: - def asbool(val): - if not val: - return False - try: - val = val.lower() - except AttributeError: - pass - if val in ('false', 'no', 'f', 'n', 'off'): - return False - return True - if asbool(self.config.get('milla.favicon')) and \ path_info == '/favicon.ico': func = FaviconController() diff --git a/src/milla/util.py b/src/milla/util.py new file mode 100644 index 0000000..61e4a6e --- /dev/null +++ b/src/milla/util.py @@ -0,0 +1,36 @@ +'''Module milla.uti + +Please give me a docstring! + +:Created: Mar 30, 2011 +:Author: dustin +:Updated: $Date$ +:Updater: $Author$ +''' + +def asbool(val): + '''Test a value for truth + + Returns ``False`` values evaluating as false, such as the integer + ``0`` or ``None``, and for the following strings, irrespective of + letter case: + + * false + * no + * f + * n + * off + * 0 + + Returns ``True`` for all other values. + ''' + + if not val: + return False + try: + val = val.lower() + except AttributeError: + pass + if val in ('false', 'no', 'f', 'n', 'off', '0'): + return False + return True \ No newline at end of file