equal
deleted
inserted
replaced
198 set (default to view.rset) to the currently displayed page |
198 set (default to view.rset) to the currently displayed page |
199 """ |
199 """ |
200 req = view._cw |
200 req = view._cw |
201 if rset is None: |
201 if rset is None: |
202 rset = view.cw_rset |
202 rset = view.cw_rset |
|
203 if w is None: |
|
204 w = view.w |
203 nav = req.vreg['components'].select_or_none( |
205 nav = req.vreg['components'].select_or_none( |
204 'navigation', req, rset=rset, page_size=page_size) |
206 'navigation', req, rset=rset, page_size=page_size) |
205 if nav: |
207 if nav: |
206 if w is None: |
208 if w is None: |
207 w = view.w |
209 w = view.w |
221 def paginate(view, show_all_option=True, w=None, page_size=None, rset=None): |
223 def paginate(view, show_all_option=True, w=None, page_size=None, rset=None): |
222 """paginate results if the view is paginable and we're not explictly told to |
224 """paginate results if the view is paginable and we're not explictly told to |
223 display everything (by setting __force_display in req.form) |
225 display everything (by setting __force_display in req.form) |
224 """ |
226 """ |
225 if view.paginable and not view._cw.form.get('__force_display'): |
227 if view.paginable and not view._cw.form.get('__force_display'): |
226 do_paginate(view, rset, w or view.w, show_all_option, page_size) |
228 do_paginate(view, rset, w, show_all_option, page_size) |
227 |
229 |
228 # monkey patch base View class to add a .paginate([...]) |
230 # monkey patch base View class to add a .paginate([...]) |
229 # method to be called to write pages index in the view and then limit the result |
231 # method to be called to write pages index in the view and then limit the result |
230 # set to the current page |
232 # set to the current page |
231 from cubicweb.view import View |
233 from cubicweb.view import View |