Hey all, Another developer and I were having two separate issues with the paginate decorator so I wrote a patch that addresses both. I wanted to toss it out here for discussion:
My problem: * I have some URLs that I want to return paginated data for when a user views it as HTML but want to return the entire list of data when a script requests JSON data. Currently there isn't a way to specify that paginate should return all the data. His problem: * Search indexers have somehow decided that they are going to index some of his paginated pages with ?tg_paginate_limit=0 at the end. This causes his log to fill up with a bunch of zeroDivisionError tracebacks[1]_ I'm attaching a patch against TG-1.0.3 that sets the tg_paginate_limit=row_count when the limit passed in is 0. This fixes my problem by giving me something that I can use to return all data (whereas both positive and negative values already have a meaning to paginate) and fixes his problem because tg_paginate_limit now has a meaning when passed in 0. Anyone have thoughts on this? Is this properly discussed in a bug report? .. _[1]: https://hosted.fedoraproject.org/projects/bodhi/ticket/150 Thanks, -Toshio
--- paginate.py.bak 2007-12-12 12:33:17.000000000 -0700
+++ paginate.py 2007-12-12 12:34:46.000000000 -0700
@@ -147,6 +147,9 @@
'Variable is not a list or SelectResults or Query (%s)' % type(
var_data))
+ # If limit is zero then return all our rows
+ if not limit_:
+ limit_ = row_count
offset = (page-1) * limit_
page_count = int(ceil(float(row_count)/limit_))
signature.asc
Description: OpenPGP digital signature

