#2318: @paginate API breakage in 1.0.8
------------------------+---------------------------------------------------
Reporter: lmacken | Owner:
Type: defect | Status: new
Priority: normal | Milestone:
Component: TurboGears | Version: 1.0.8
Severity: major | Resolution:
Keywords: |
------------------------+---------------------------------------------------
Comment (by toshio):
I'm seeing a couple things in the code that look like they contribute to
this problem. I've got a prelimininary patch. I'll paste it here before
attaching so I can explain what I think is going on :-)
{{{
@param max_limit: The maximum number to which the imposed limit
- can be increased using the dynamic_limit keyword argument in the URL.
+ can be increased using the tp_paginate_limit keyword argument in the
URL.
If this is set to 0, no dynamic change at all will be allowed;
if it is set to None, any change will be allowed.
@type max_limit: int
}}}
This hunk is just documentation. AFAICS, there's no dynamic_limit keyword
argument being parsed in the code. This is a separate issue from the
other, code, changes.
{{{
@@ -150,9 +150,14 @@ def paginate(var_name, default_order='',
redirect(cherrypy.request.path_info,
cherrypy.request.params)
try:
- limit_ = int(kwpop('limit'))
+ limit_ = int(kwpop('limit'), None)
+ if limit_ is None:
+ # limit not specified by user, use default
+ raise ValueError
}}}
I think this hunk is why limit without max_limit isn't working.
Currently, if no limit is specified in the URL, we end up using min(None,
max_limit) which is None. Checking for None and using the limit specified
to the paginate decorator seems like the right thing to do.
{{{
if max_limit is not None:
- if max_limit <= 0 and not allow_limit_override:
+ if max_limit <= 0 or not allow_limit_override:
+ # Old and new way of specifying that user can't
change
+ # default, use default
raise ValueError
limit_ = min(limit_, max_limit)
except (TypeError, ValueError):
}}}
This hunk fixes max_limit having no effect unless allow_limit_override is
specified as well.
--
Ticket URL: <http://trac.turbogears.org/ticket/2318#comment:1>
TurboGears <http://www.turbogears.org/>
TurboGears front-to-back web development
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "TurboGears Tickets" group.
This group is read-only. No posting by normal members allowed.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/turbogears-tickets?hl=en?hl=en
-~----------~----~----~----~------~----~------~--~---