Am 15.04.2010 10:57 schrieb jo:
I suppose you tried without no values at all in the column data_fine
in all rows, in such case there's no error because it compares None
with None, try to insert a date in almost one row and you will see
the error.
No, I tested with 12 existing records to check that the pagination
works, and one had data_fine=null. Tried with Postgres and SQLite, both
worked. The record with data_fine=null was sorted last, and when I
clicked again, it was sorted first.
furthermore, I'm trying to understand how sorting works,
(default_order without minus sign = ORDER BY ASC, rigth?)
Yes, you can set default_order='-data_fine' for instance.
http://tg11.sfera.com/specie/?grid_params_tgp_ordering=
> specie_cod_gruppo_specie&grid_params_tgp_limit=10&
> grid_params_tgp_order=specie_cod_gruppo_specie&
> grid_params_tgp_no=1
>
Here I expected -specie_cod_gruppo_specie instead of
specie_cod_gruppo_specie, infact the order by is desc
sql: select * from specie order by cod_gruppo_specie desc; (*)
The tgp_ordering parameter is used to pass the *current* ordering (as
displayed), the tgp_order parameter passes the column you clicked. So if
the ordering is currently ASC, and you click on the column, it will
become DESC.
The mechanism is actually much simpler than it was before 1.0.5. Maybe
you think too complicated ;-)
(*) paginate sorts the columns with None in a different way from Postgres.
You mean when it sorts in memory?
You can force sorting in memory by appending .all() to your query. Then
SA will fetch all records, so it will be too late for sorting in the
database, and TG resorts to sorting in memory. The only difference I see
is that sorting datetime columns with None values does not work because
Python does not want to do this.
If you really need to sort datetimes in memory, you can overcome this
problem easily by adding a sortable column like this:
class Specie:
@property
def data_ordinare(self):
return self.data_fine or datetime.max
-- Christoph
--
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.