It's my bad. I save the template file as list.htm, but in the folder
there is a list.html which is rendered therefore shows nothing. I
thought it was a coding error so I did check that.
Sorry Mike, and thanks for your help!

On Dec 2, 9:50 pm, minglee <[EMAIL PROTECTED]> wrote:
> Hi, Mike,Thanks.
> I tried according to what you said. But failed. No related html code
> genrated.
>
> Calvin.
>
> On Dec 2, 5:04 pm, "Mike Orr" <[EMAIL PROTECTED]> wrote:
>
> > On Tue, Dec 2, 2008 at 12:28 AM, minglee <[EMAIL PROTECTED]> wrote:
>
> > > The controller is like:
> > >  def list(self):
> > >    records = meta.Session.query(model.Page)
> > >    c.paginator = paginate.Page(
> > >        records,
> > >        page=int(request.params.get('page', 1)),
> > >        items_per_page = 10,
> > >    )
> > >    return render('/derived/page/list.html')
> > > And list.html is:
> > > <%inherit file="/base/index.html" />
>
> > > <%def name="heading()"><h1>Page List</h1></%def>
>
> > > <%def name="buildrow(page, odd=True)">
> > >    %if odd:
> > >        <tr class="odd">
> > >    %else:
> > >        <tr class="even">
> > >    % endif
> > >        <td valign="top">
> > >            ${h.link_to(
> > >                page.id,
> > >                h.url_for(
> > >                    controller=u'page',
> > >                    action='view',
> > >                    id=unicode(page.id)
> > >                )
> > >            )}
> > >        </td>
> > >        <td valign="top">
> > >            ${page.title}
> > >        </td>
> > >        <td valign="top">${page.posted.strftime('%c')}</td>
> > >        </tr>
> > > </%def>
>
> > > % if len(c.paginator):
> > > <p>${ c.paginator.pager('$link_first $link_previous $first_item to
> > > $last_item of $item_count $link_next $link_last') }</p>
> > > <table class="paginator"><tr><th>Page ID</th><th>Page Title</
> > > th><th>Posted</th></tr>
> > > <% counter=0 %>
> > > % for item in c.paginator:
> > >    ${buildrow(item, counter%2)}
> > >    <% counter += 1 %>
> > > % endfor
> > > </table>
> > > <p>${ c.paginator.pager('~2~') }</p>
> > > % else:
> > > <p>No pages have yet been created. <a href="${h.url_for
> > > (controller='page', action='new')}">Add one</a>.</p>
> > > % endif
> > > However when I try to browse it, nothing show up in browser.
> > > Messages showed by server in command line are:
> > > 16:13:02,312 INFO  [sqlalchemy.engine.base.Engine.0x...a450] BEGIN
> > > 16:13:02,328 INFO  [sqlalchemy.engine.base.Engine.0x...a450] SELECT
> > > page.id AS p
> > > age_id, page.content AS page_content, page.posted AS page_posted,
> > > page.title AS
> > > page_title, page.heading AS page_heading
> > > FROM page
> > > 16:13:02,328 INFO  [sqlalchemy.engine.base.Engine.0x...a450] []
> > > Anybody help me ? thanks!
>
> > Try changing "% if len(c.paginator):" to "% if True:".  If that works,
> > the problem is that the underlying iterable does not have a length.  I
> > would expect an AttributeError in that case, but it's possible the
> > error is being suppressed for some reason.
>
> > Also, check "view source" in your browser.  It's possible that it's
> > outputting empty HTML tags, which are invisible.
>
> > If that doesn't work, tomorrow I can check my work application to see
> > how I handled it.  There should also be a paginator attribute for the
> > record count, which is the same as what the length would be.
>
> > --
> > Mike Orr <[EMAIL PROTECTED]>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" 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/pylons-discuss?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to