paginate and default

1 view
Skip to first unread message

Sanjay

unread,
Dec 12, 2006, 6:56:13 AM12/12/06
to TurboGears
Hi all,

I have a controller method to show some data in a grid (not using
widgets), like this:

@expose(...)
def show_list(self, param1, param2)
.
.
.

And I do the URL mapping like this:

@expose(...)
def default(param0, param1, param2)
.
.
.
if param0 == 'xyz'
return show_list(param1, param2)
.
.
.

Now, to implement paginate, I had to change the default method like
this:

@expose(...)
def default(param0, param1, param2, **paginate_parameters)
.
.
.
if param0 == 'xyz'
paginate_parameters.update({'param1' : param1, 'param2' :
param2})
raise redirect(turbogears.url('/xyz', paginate_parameters))
.
.
.

Also, in the template, href_next and href_prev did not reflect param1
and param2, and I had to construct those manually like this:

<a py:if="tg.paginate.current_page != 1"
href="${tg.url('/' + param1 + '/' + param2,
tg_paginate_limit=tg.paginate.limit,
tg_paginate_no=tg.paginate.current_page-1)}">previous
</a>

Being an amateur, I doubt whether I am making things complex - there
might be simpler ways. Seeking suggestions.

thanks
sanjay

Sanjay

unread,
Dec 12, 2006, 11:57:47 PM12/12/06
to TurboGears
To summarize, I was presenting a way and then seeking suggestions on
how to use @paginate with a controller method, say foo, where

1. foo has some parameters
2. foo is called from default

thanks
sanjay

Reply all
Reply to author
Forward
0 new messages