Ticket #1889 (closed defect: fixed)
paginate works only with tg.strict_parameters = True
| Reported by: | chrisz | Owned by: | anonymous |
|---|---|---|---|
| Priority: | normal | Milestone: | 1.1b1 |
| Component: | TurboGears | Version: | 1.1 HEAD |
| Severity: | major | Keywords: | paginate strict_parameters |
| Cc: |
Description
The paginate decorator works fine with tg.strict_parameters = True as set in the default dev.cfg, but this is not the default and not set in the sample prod.cfg. In this case, if tg.strict_parameters = False, then paginate works only for methods having the paginate parameters explicitly declared or catching additional parameters with **kwargs. The reason is that if you set tg.strict_parameters = False, then all additional parameters are thrown away by TurboGears with adapt_call(), including the paginate parameters, so paginate never sees them.
Something should be done about this, since it's pretty confusing when paginate suddenly stops working in production.
See also this thread on the turbogears mailing list.
Attachments
Change History
comment:2 Changed 5 years ago by faide
This one is a tough one. What kind of fix do you propose chrisz ?
Changed 5 years ago by chrisz
-
attachment
paginate_strict.patch
added
Patch for allowing paginate with strict_parameters
comment:3 Changed 5 years ago by chrisz
I have added a patch that makes paginate work with strict_parameters=False. It adds an attribute for declaring a set of such additional parameters for a controller method and modifies paginate so that it sets this attribute for the paginated function.
comment:4 Changed 5 years ago by Chris Arndt
Patch looks good. Test please?
The paginate decorator function could use some refactoring (in TG 1.1). It's now over 200 lines of code long!
comment:5 Changed 5 years ago by chrisz
- Version changed from 1.0.5 to 1.1 HEAD
- Milestone changed from 1.0.x bugfix to 1.1 beta 1
Checked in with tests in r5311 for TG 1.0, need to port this to TG 1.1 and 1.5. (In 1.1 paginate is already a bit simpler because deprecated stuff like support for 'tg_paginate_' parameters and Py 2.3 has been removed, though some refactoring would still be good.)
As an intermediate measure, I have put a reference to this ticket in the FAQ list at the end of the paginate documentation.