Warning:
Can't synchronize with repository "(default)" (Unsupported version control system "svn": No module named svn). Look in the Trac log for more information.
| File paginate_strict.patch,
1.8 KB
(added by chrisz, 3 years ago) |
|
Patch for allowing paginate with strict_parameters
|
-
|
|
|
|
| 394 | 394 | tg_util.remove_keys(kw, ["tg_random", "tg_format"] |
| 395 | 395 | + config.get("tg.ignore_parameters", [])) |
| 396 | 396 | else: |
| | 397 | try: |
| | 398 | tg_kw = dict([(k, v) for k, v in kw.items() if k in func._tg_args]) |
| | 399 | except AttributeError: |
| | 400 | tg_kw = {} |
| 397 | 401 | args, kw = tg_util.adapt_call(func, args, kw) |
| | 402 | kw.update(tg_kw) |
| 398 | 403 | if config.get('server.environment', 'development') == 'development': |
| 399 | 404 | # Only output this in development mode: If it's a field storage object, |
| 400 | 405 | # this means big memory usage, and we don't want that in production |
-
|
|
|
|
| 112 | 112 | |
| 113 | 113 | def entangle(func): |
| 114 | 114 | |
| | 115 | get = turbogears.config.get |
| | 116 | |
| 115 | 117 | def decorated(func, *args, **kw): |
| 116 | 118 | |
| 117 | | get = turbogears.config.get |
| 118 | | |
| 119 | 119 | def kwpop(name, default=None): |
| 120 | 120 | return kw.pop(var_name + '_tgp_' + name, |
| 121 | 121 | kw.pop('tg_paginate_' + name, default)) |
| … |
… |
|
| 298 | 298 | for i in xrange(offset, endpoint)] |
| 299 | 299 | |
| 300 | 300 | return output |
| | 301 | if not get('tg.strict_parameters', False): |
| | 302 | try: |
| | 303 | args = func._tg_args |
| | 304 | except AttributeError: |
| | 305 | args = set() |
| | 306 | for arg in 'no', 'limit', 'order', 'ordering': |
| | 307 | args.add(var_name + '_tgp_' + arg) |
| | 308 | args.add('tg_paginate' + arg) |
| | 309 | func._tg_args = args |
| 301 | 310 | return decorated |
| 302 | 311 | return weak_signature_decorator(entangle) |
| 303 | 312 | |
Download in other formats: