I just started using the paginate decorator, and what I wanted to do was
to be able to do was index the pages alphabetically the way a dictionary
(the printed kind) might do: [A-be, be-bi, bi-ca .....]. Is there a way
to do this?
I came up with a work-around to do this, which I'm including in case
someone else wants to do something similar.
----------------
PAGE_LIMIT = 250
@expose(template="/asset.mak")
@identity.require(identity.not_anonymous())
@paginate('children',
default_order='name',limit=PAGE_LIMIT,max_pages=20)
def index(self, path=SHOW_ROOT,**data):
#---snip -----#
data_index=[]
for step in range (0,len(children),PAGE_LIMIT):
page_end = step+PAGE_LIMIT
if page_end > len(children):
page_end=len(children)
data_index.append((children[step].name[0:5],
children[page_end-1].name[0:5]))
Then in my view I do (I'm using Mako):
% if tg.paginate.page_count > 1:
<span>[</span>
% for page in tg.paginate.pages:
<% s="%s-%s" % data_index[page-1] %>
% if page == tg.paginate.current_page:
<span style="text-decoration:underline;color:000;">${s}</span>
% else:
<span><a href="${tg.paginate.get_href(page)}">${s}</a></span>
% endif
% if page < tg.paginate.page_count:
<span>|</span>
% endif
% endfor
<span>]</span>
--
David Gardner
Pipeline Tools Programmer, "Sid the Science Kid"
Jim Henson Creature Shop
[EMAIL PROTECTED]
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"TurboGears" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/turbogears?hl=en
-~----------~----~----~----~------~----~------~--~---