doc: Fix incorrect example for req.get_param() in README.md
As of version 0.1.4, req.get_param() no longer accepts a "default"
parameter. Instead, callers are encourage to use the idiomatic
python "or" pattern. For example:
limit = req.get_param('limit') or 10
Fixes #132
This commit is contained in:
@@ -134,8 +134,8 @@ class ThingsResource:
|
|||||||
self.logger = logging.getLogger('thingsapi.' + __name__)
|
self.logger = logging.getLogger('thingsapi.' + __name__)
|
||||||
|
|
||||||
def on_get(self, req, resp, user_id):
|
def on_get(self, req, resp, user_id):
|
||||||
marker = req.get_param('marker', default='')
|
marker = req.get_param('marker') or ''
|
||||||
limit = req.get_param_as_int('limit', default=50)
|
limit = req.get_param_as_int('limit') or 50
|
||||||
|
|
||||||
try:
|
try:
|
||||||
result = self.db.get_things(marker, limit)
|
result = self.db.get_things(marker, limit)
|
||||||
|
|||||||
@@ -412,8 +412,8 @@ class Request(object):
|
|||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
The value of the param if it is found and can be converted to an
|
The value of the param if it is found and can be converted to an
|
||||||
integer. If the param is not found, returns None, unless
|
integer. If the param is not found, returns None, unless required
|
||||||
unless required is True.
|
is True.
|
||||||
|
|
||||||
Raises
|
Raises
|
||||||
HTTPBadRequest: The param was not found in the request, even though
|
HTTPBadRequest: The param was not found in the request, even though
|
||||||
|
|||||||
Reference in New Issue
Block a user