Merge pull request #325 from seemethere/add_key_error
Simplify RequestParameters
This commit is contained in:
commit
e5cbf25cbd
|
@ -21,19 +21,13 @@ class RequestParameters(dict):
|
||||||
value of the list and getlist returns the whole shebang
|
value of the list and getlist returns the whole shebang
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
|
||||||
self.super = super()
|
|
||||||
self.super.__init__(*args, **kwargs)
|
|
||||||
|
|
||||||
def __getitem__(self, name):
|
|
||||||
return self.get(name)
|
|
||||||
|
|
||||||
def get(self, name, default=None):
|
def get(self, name, default=None):
|
||||||
values = self.super.get(name)
|
"""Return the first value, either the default or actual"""
|
||||||
return values[0] if values else default
|
return super().get(name, [default])[0]
|
||||||
|
|
||||||
def getlist(self, name, default=None):
|
def getlist(self, name, default=None):
|
||||||
return self.super.get(name, default)
|
"""Return the entire list"""
|
||||||
|
return super().get(name, default)
|
||||||
|
|
||||||
|
|
||||||
class Request(dict):
|
class Request(dict):
|
||||||
|
|
Loading…
Reference in New Issue
Block a user