From: Joseph Spiros Date: Wed, 11 Aug 2010 22:46:32 +0000 (-0400) Subject: Merge branch 'master' of git://github.com/melinath/philo X-Git-Tag: philo-0.9~39 X-Git-Url: http://git.ithinksw.org/philo.git/commitdiff_plain/d9d4177c5f384c55b3f3445c660632780cdfbd83?hp=781cf86e935c66069acd17878a9f3de7cc6ec231 Merge branch 'master' of git://github.com/melinath/philo * 'master' of git://github.com/melinath/philo: Adjusted the paginate function to only attempt a length check if per_page is valid. Addresses bug #19. --- diff --git a/utils.py b/utils.py index efd9f98..6fc2cff 100644 --- a/utils.py +++ b/utils.py @@ -74,15 +74,15 @@ def paginate(objects, per_page=None, page_number=1): except (TypeError, ValueError): # Then either it wasn't set or it was set to an invalid value paginator = page = None - - # There also shouldn't be pagination if the list is too short. Try count() - # first - good chance it's a queryset, where count is more efficient. - try: - if objects.count() <= per_page: - paginator = page = None - except AttributeError: - if len(objects) <= per_page: - paginator = page = None + else: + # There also shouldn't be pagination if the list is too short. Try count() + # first - good chance it's a queryset, where count is more efficient. + try: + if objects.count() <= per_page: + paginator = page = None + except AttributeError: + if len(objects) <= per_page: + paginator = page = None try: return paginator, page, objects