how to create multiple pagination objects

1 view
Skip to first unread message

amarsibia

unread,
Mar 25, 2008, 10:55:28 PM3/25/08
to TurboGears
i want to make 2 pagination objects 1 for blogs and 1 for links (these
user blog links) i have read that it is now possible since TG 1.0.2
but have no idea how to implement it. currently i am doing

@expose(template='kid:tblog.BlogEntryController.templates.list')
@paginate('records', limit=10)
@paginate('users', limit=1)
def list(self, **kw):
users = User.select(orderBy=User.q.display_name)
"""List records in model"""
records = BlogEntry.select()
return dict(records = records, modelname=self.modelname,
users=users)

it correctly limits the select() items, but it wont show the paginate
links, im using the following code to display my paginate:

<span py:for="page in tg.paginate.pages">
<a py:if="page != tg.paginate.current_page" href="$
{tg.paginate.get_href(page)}">${page}</a>
<span py:if="page == tg.paginate.current_page">${page}</span>
</span>

However it is the same for both objects, i dont know how to declare it
to use a different paginate object. any help would be brilliant.

Roger Demetrescu

unread,
Mar 26, 2008, 6:51:20 AM3/26/08
to turbo...@googlegroups.com


Instead of tg.paginate.xxxxx, try using tg.paginates['users'].xxxxx and
tg.paginates['records'].xxxxx inside your template.

tg.paginates is a dictionary containing all paginates objects.
tg.paginate points to the last paginate object processed by paginate
decorator. (too many "paginate" sentences in this sentence, I know
:))


Cheers,

Roger


>
> >
>

amarsibia

unread,
Mar 26, 2008, 2:36:14 PM3/26/08
to TurboGears
Thank you so much i just couldn't find that syntax anywhere

On Mar 26, 10:51 am, "Roger Demetrescu" <roger.demetre...@gmail.com>
wrote:

Roger Demetrescu

unread,
Mar 26, 2008, 2:49:43 PM3/26/08
to turbo...@googlegroups.com
On 3/26/08, amarsibia <amar...@googlemail.com> wrote:
>
> Thank you so much i just couldn't find that syntax anywhere
>

Yeaph, I know...
This is one of new features paginate decorator has which isn't
documented already.. :(

For now, try searching for 'pagina' in changelog to have an idea of
what have been changed recently..

http://trac.turbogears.org/wiki/ChangeLog

[]s
Roger

Florent Aide

unread,
Mar 26, 2008, 5:51:06 PM3/26/08
to turbo...@googlegroups.com
On Wed, Mar 26, 2008 at 7:49 PM, Roger Demetrescu
<roger.de...@gmail.com> wrote:
>
> On 3/26/08, amarsibia <amar...@googlemail.com> wrote:
> >
> > Thank you so much i just couldn't find that syntax anywhere
> >
>
> Yeaph, I know...
> This is one of new features paginate decorator has which isn't
> documented already.. :(

Roger you're still alive!
I was waiting for this documentation! :-)

Cheers,
Florent.

Reply all
Reply to author
Forward
0 new messages