Christoph Zwerschke wrote:
Am 28.04.2010 17:16 schrieb jose soares:
I have yet some troubles with paginate sorting.
It sorts a table with few rows, but it doesn't sort with many rows.
I'm trying it with 8105 rows.
@tg.paginate(dynamic_limit='limit',var_name='grid_params',
default_order='comune_nome', max_limit=None)
What's wrong with it?
Check help(paginate) or the detailed documentation available here:
http://docs.turbogears.org/1.0/PaginateDecorator
There is a limit of 1000 rows up to which paginate sorts in memory,
because sorting in memory can be time and memory consuming.
It is possible to increase this limit with the max_sort parameter, e.g.
@tg.paginate(max_sort=10000, ...)
But you should better check why paginate is sorting your data in
memory in the first place. If you pass a SQLAlchemy or SQLObject
query, then TurboGears will normally do the sorting in the database.
So you're probably passing a list instead of a query.
Btw, you can also add the following to your dev.cfg file for debugging
the paginate decorator:
[[[turbogears.paginate]]]
level='DEBUG'
Hope this helps,
-- Christoph
here what debug says:
DEBUG Starting SA transaction
DEBUG Calling <function index at 0x5d50230> with
*((<sicer.BASE.controller.tabelleCodifica.comune.Controller object at 0x68
DEBUG paginate params: page=1, limit=12, order=comune_cod_provincia
DEBUG paginate: ordering was ['comune_cod_provincia', 'comune_nome'],
sort is comune_cod_provincia
DEBUG paginate: ordering is ['-comune_cod_provincia', 'comune_nome']
DEBUG paginate: sorting in memory not allowed
DEBUG paginate: slicing data between 0 and 12
INFO MochiKit version chosen: 1.3.1
DEBUG Compiling template for turbogears.view.templates.sitetemplate
DEBUG Compiling template for sicer.BASE.view.templates.edit
DEBUG Applying template sicer.BASE.view.templates.edit
DEBUG Compiling template for sicer.BASE.view.widgets.templates.TableForm
DEBUG Compiling template for sicer.BASE.view.widgets.templates.FieldSet
DEBUG Compiling template for
turbogears.widgets.templates.paginate_datagrid
DEBUG Transaction is still active - will commit now
DEBUG Ending SA transaction
------------------
and now it works properly with max_sort=10000 in paginate decorator:
DEBUG Starting SA transaction
DEBUG Calling <function index at 0x4c1a230> with
*((<sicer.BASE.controller.tabelleCodifica.comune.Controller object at 0x57
DEBUG paginate params: page=1, limit=12, order=comune_cod_provincia
DEBUG paginate: ordering was ['-comune_cod_provincia',
'comune_nome'], sort is comune_cod_provincia
DEBUG paginate: ordering is ['comune_cod_provincia', 'comune_nome']
DEBUG paginate: slicing data between 0 and 12
INFO MochiKit version chosen: 1.3.1
DEBUG Compiling template for turbogears.view.templates.sitetemplate
DEBUG Compiling template for sicer.BASE.view.templates.edit
DEBUG Applying template sicer.BASE.view.templates.edit
DEBUG Compiling template for sicer.BASE.view.widgets.templates.TableForm
but I'm passing it a SQLAlchemy object query not a list:
return dict( grid = w.PaginateDataGrid(fields=gridFields), grid_params =
Comune.query() )
print Comune.query() )
<sqlalchemy.orm.query.Query object at 0x6d03810>
j
--
You received this message because you are subscribed to the Google Groups
"TurboGears" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/turbogears?hl=en.