[ckan-changes] [okfn/ckan] 898f31: Fix a bug with the limit argument to current_packa...
GitHub
noreply at github.com
Thu May 3 14:24:08 UTC 2012
Branch: refs/heads/feature-2345-action-api-autodocs
Home: https://github.com/okfn/ckan
Commit: 898f31d872db3bcbe1af8f602699d3ba8b82f06d
https://github.com/okfn/ckan/commit/898f31d872db3bcbe1af8f602699d3ba8b82f06d
Author: Sean Hammond <seanhammond at lavabit.com>
Date: 2012-05-03 (Thu, 03 May 2012)
Changed paths:
M ckan/logic/action/get.py
Log Message:
-----------
Fix a bug with the limit argument to current_package_list_with_resources
diff --git a/ckan/logic/action/get.py b/ckan/logic/action/get.py
index 2dc4d30..4b6051b 100644
--- a/ckan/logic/action/get.py
+++ b/ckan/logic/action/get.py
@@ -65,7 +65,15 @@ def package_list(context, data_dict):
def current_package_list_with_resources(context, data_dict):
model = context["model"]
user = context["user"]
- limit = data_dict.get("limit")
+ if data_dict.has_key('limit'):
+ try:
+ limit = int(data_dict['limit'])
+ if limit < 0:
+ limit = 0
+ except ValueError, e:
+ raise logic.ParameterError("'limit' should be an int")
+ else:
+ limit = None
page = int(data_dict.get('page', 1))
check_access('current_package_list_with_resources', context, data_dict)
@@ -75,8 +83,8 @@ def current_package_list_with_resources(context, data_dict):
query = query.filter(model.PackageRevision.current==True)
query = query.order_by(model.package_revision_table.c.revision_timestamp.desc())
- if limit:
- query = query.limit(int(limit))
+ if limit is not None:
+ query = query.limit(limit)
query = query.offset((page-1)*limit)
pack_rev = query.all()
return _package_list_with_resources(context, pack_rev)
================================================================
More information about the ckan-changes
mailing list