Browse Source

Avoid index error if there aren't pages when iterating for paginator.

main
justin 12 years ago
parent
commit
ded3fad91f
1 changed files with 15 additions and 14 deletions
  1. +15
    -14
      hyde/ext/plugins/paginator.py

+ 15
- 14
hyde/ext/plugins/paginator.py View File

@@ -93,20 +93,21 @@ class Paginator:
""" """
added_resources = [] added_resources = []
pages = list(self._walk_pages_in_node(node)) pages = list(self._walk_pages_in_node(node))
deps = reduce(list.__add__, [page.posts for page in pages], [])

Paginator._attach_page_to_resource(pages[0], resource)
Paginator._add_dependencies_to_resource(deps, resource)
for page in pages[1:]:
# make new resource
new_resource = self._new_resource(resource, node, page.number)
Paginator._attach_page_to_resource(page, new_resource)
new_resource.depends = resource.depends
added_resources.append(new_resource)

for prev, next in pairwalk(pages):
next.previous = prev
prev.next = next
if pages:
deps = reduce(list.__add__, [page.posts for page in pages], [])

Paginator._attach_page_to_resource(pages[0], resource)
Paginator._add_dependencies_to_resource(deps, resource)
for page in pages[1:]:
# make new resource
new_resource = self._new_resource(resource, node, page.number)
Paginator._attach_page_to_resource(page, new_resource)
new_resource.depends = resource.depends
added_resources.append(new_resource)

for prev, next in pairwalk(pages):
next.previous = prev
prev.next = next


return added_resources return added_resources




Loading…
Cancel
Save