Added a `util` module and moved the `asbool` function there
parent
c744d79422
commit
303b0ff880
|
@ -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()
|
||||
|
|
|
@ -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
|
Loading…
Reference in New Issue