summaryrefslogtreecommitdiff
path: root/trove/common/utils.py
diff options
context:
space:
mode:
authorIshita Mandhan <imandha@us.ibm.com>2015-10-14 16:22:54 -0700
committerIshita Mandhan <imandha@us.ibm.com>2015-10-16 08:11:30 -0700
commit0746e70cb5e367d89980f4e1166458afed194fe1 (patch)
tree51e14f0b881c03ef4dcea441d70c5c4a637049bb /trove/common/utils.py
parent87753afeb2ec8a136ddb626fdd14f3e5c6d4c623 (diff)
downloadtrove-0746e70cb5e367d89980f4e1166458afed194fe1.tar.gz
Pagination limit code refactor
The logic to find the pagination limit is repeated several times and is not in one function. This patch creates a function that is called in various locations replacing repetitive code. Change-Id: I3eced6a4236e4189e57ea5a1589e8f0d411cc4e3 Closes-Bug: #1308285
Diffstat (limited to 'trove/common/utils.py')
-rw-r--r--trove/common/utils.py5
1 files changed, 5 insertions, 0 deletions
diff --git a/trove/common/utils.py b/trove/common/utils.py
index 85fd27ed..a307d8a8 100644
--- a/trove/common/utils.py
+++ b/trove/common/utils.py
@@ -54,6 +54,11 @@ ENV = jinja2.Environment(loader=jinja2.ChoiceLoader([
]))
+def pagination_limit(limit, default_limit):
+ limit = int(limit or default_limit)
+ return min(limit, default_limit)
+
+
def create_method_args_string(*args, **kwargs):
"""Returns a string representation of args and keyword args.