On Thu, Apr 23, 2009 at 12:08 PM, Christoph Haas
<em...@christoph-haas.de> wrote:
> Moin, Clemens...
>
> Am Donnerstag, 16. April 2009 18:49:10 schrieb Clemens Hermann:
>> if routes.Mapper is configured with explicit=True (as recommended)
>> then webhelpers.paginate.Page._pagerlink fails. The reason for this is
>> that _pagerlink relies on route memory which is not present in case of
>> explicit=True.

I think I ran into this problem and worked around it by making my
template at a higher level that avoids pagelink.  Here's the Mako code
I use to generate a paged region with a navbar on top and bottom.
Note that Mako uses the pager object only for the records and page
numbers, and generates the URLs itself using h.url_for in the normal
way.  There's some support for Ajax ('partial' parameter) but I'm not
using it so I'm not sure it's fully working.

===
## ************ PAGED REGION *******************
<%def name="paged(page, whats, route_name, query_params)">
<%
    """Put a paged section on a webpage, with links to the other pages.

       page:        A Page object from Christoph Haas' 'paginate' package.
       whats:       A plural word describing the elements in the page.
       route_name:  Name of route for URL generation.
       query_params:      Dict of query params for URL generation.

       Your controller action should look for the 'partial' query parameter.
       If present, return the paged region indicated by its value rather than
       the entire HTML page.
    """
%>
% if page.item_count == 0 or page.first_item is None:
<p class="instructions">No ${whats}
${"found" if page.item_count == 0 else "on this page"}.</p>
<%   return   %>
% endif
  <%def name="navigator()">
    <%
        params = query_params or {}
        prev = max(page.page-1, page.first_page)
        next = min(page.page+1, page.last_page)
        is_first_page = page.page == page.first_page
        is_last_page = page.page == page.last_page
    %>
    <br />
    <div class="navigator" style="clear:all">
      Page <b>${page.page}</b> of <b>${page.last_page}</b> &nbsp;
      <span class="navigator-button">
        ${h.link_to_unless(
          is_first_page,
          literal("&lt;&lt; First"),
          h.url_for(route_name, page=page.first_page, **params))}
      </span>
      <span class="navigator-button">
        ${h.link_to_unless(
          is_first_page,
          literal("&lt; Prev"),
          h.url_for(route_name, page=prev, **params))}
      </span>
      <span class="navigator-button">
        ${h.link_to_unless(
          is_last_page,
          literal("Next &gt;"),
          h.url_for(route_name, page=next, **params))}
      </span>
      <span class="navigator-button">
        ${h.link_to_unless(
          is_last_page,
          literal("Last &gt;&gt;"),
          h.url_for(route_name, page=page.last_page, **params))}
      </span>
      <form action="${h.url_for(route_name, **params)}"
        type="get" class="noFrills" style="display:inline">
        % for name, value in params.iteritems():
        ${h.hidden(name, value)}
        % endfor   params
        Page#
        <input type="text" name="page" size="4" value="">
        <input type="submit" name="submit" value="Go">
      </form>
    </div>
    <br clear="all" />  <!-- You'd think it wouldn't be necessary, but. -->
  </%def>
<div id="dynamic">
    <div>
        Displaying ${whats} ${page.first_item}
        to ${page.last_item} of ${page.item_count}.
    </div>
    <div>${navigator()}</div>
    <div style="margin: 0.5em 0">
${caller.body()}
    </div>
    <div>${navigator()}</div>
</div>
</%def>
===

-- 
Mike Orr <sluggos...@gmail.com>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"pylons-devel" group.
To post to this group, send email to pylons-devel@googlegroups.com
To unsubscribe from this group, send email to 
pylons-devel+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/pylons-devel?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to