Pagination and tg.strict_parameters

0 views
Skip to first unread message

King Simon-NFHD78

unread,
Apr 5, 2007, 6:52:11 AM4/5/07
to turbo...@googlegroups.com
Hi,

(All this relates to TG 1.0.1)

The paginate decorator stops working when you switch from dev.cfg to a
config based on sample-prod.cfg. This seems to have caught people
before:

http://groups.google.com/group/turbogears/browse_thread/thread/11d1fa772
86eab6f/e0d41ce6cb53ab4a
http://trac.turbogears.org/ticket/845
http://trac.turbogears.org/ticket/1013

and seems to be down to these lines in controllers._execute_func:

if config.get("tg.strict_parameters", False):
tg_util.remove_keys(kw, ["tg_random", "tg_format"])
else:
args, kw = tg_util.adapt_call(func, args, kw)

ie. when tg.strict_parameters is False or undefined (the default in
sample-prod.cfg), then adapt_call is used to strip unknown parameters,
and that seems to include the pagination ones.

One workaraound is to enable tg.strict_parameters, but this may have
undesired effects in other parts of your application. Another is to add
**kwargs to the method that you want to paginate, which will cause
adapt_call to pass all arguments through, but this is a bit of a hack.

I don't know how to fix this in the general case - adapt_call would have
to be able to figure out the parameters that paginate requires, but
since paginate uses **kwargs that would be impossible. Perhaps if
paginate explicitly named its parameters, then adapt_call could do the
right thing?

The two attached files show the problem when added to the TurboGears
test suite.

Cheers,

Simon

test_paginate_template.kid
test_paginate.py
Reply all
Reply to author
Forward
0 new messages