Consistent _get_multi_param() function in responses
This abstracts _get_multi_param() into BaseResponse and makes it always ensure that the string it has been given ends with a '.'. It had been implemented in three different places, and in use it rarely postpended a trailing period, which could make it match parameters it shouldn't have.
This commit is contained in:
parent
745368242e
commit
fab37942c4
4 changed files with 10 additions and 16 deletions
|
|
@ -66,6 +66,14 @@ class BaseResponse(object):
|
|||
def _get_param(self, param_name):
|
||||
return self.querystring.get(param_name, [None])[0]
|
||||
|
||||
def _get_multi_param(self, param_prefix):
|
||||
if param_prefix.endswith("."):
|
||||
prefix = param_prefix
|
||||
else:
|
||||
prefix = param_prefix + "."
|
||||
return [value[0] for key, value in self.querystring.items()
|
||||
if key.startswith(prefix)]
|
||||
|
||||
|
||||
def metadata_response(request, full_url, headers):
|
||||
"""
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue