fdom = open(domain_file, "r")
class MyNestedMultiDict(multidict.NestedMultiDict):
def get_int(self, key, default=None):
"""
@rtype int
"""
try:
return int(self[key])
except (KeyError, ValueError):
return default
def get_float(self, key, default=None):
"""
@rtype float
"""
try:
return float(self[key])
except (KeyError, ValueError):
return default
def get_bool(self, key, default=None):
"""
@rtype bool
"""
try:
value = self[key]
if value in ('1', 'true', 'True', 'on', True, 1):
return True
if value in ('', '0', 'false', 'False', 'off', False, 0):
return False
return default
except (KeyError, ValueError):
return default
class MyRequest(request.Request):
@property
def params(self):
"""
A dictionary-like object containing both the parameters from
the query string and request body.
@rtype : .request.MyNestedMultiDict
"""
params = MyNestedMultiDict(self.GET, self.POST)
return params