Christoph Zwerschke wrote:
Am 14.04.2010 08:24 schrieb jo:
Traceback (most recent call last):
File "<stdin>", line 1, in ?
TypeError: can't compare datetime.date to NoneType
Contrary to other Python 2 types, you can't compare dates with None
values or other objects of a different type (i.e. date behaves already
as all objects do in Python 3).
One solution is to create your own date class which will treat None as
-infinity or +infinity. Or just use ISO-formatted strings.
If your data is coming from a database, you should also check whether
you can do the sorting via SQL in the database. The paginate decorator
tries to do that with query results if you use it properly.
Thank you Christoph for reply my answer.
My source is a query object of SA and data comming from db already
sorted but when I click on the column title, paginate tries to ordering
it again and raises this error.
The paginate decorator for 1.x is pretty well documented:
http://docs.turbogears.org/1.0/PaginateDecorator
I have reading the documentation but I cannot understand how paginate works.
Take a look at this example...
When I click on gruppo_specie I can see the following 10 rows:
?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
codice descrizione gruppo_specie
------ --------------------- -------------
08 Altre specie avicole ALTRE SPECIE
0140 Struzzo AVICOLI
0137 Oca AVICOLI
0143 Emu AVICOLI
0136 Piccione AVICOLI
0138 Faraona AVICOLI
0139 Fagiano AVICOLI
0133 Pernice AVICOLI
0134 Quaglie AVICOLI
0135 Starna AVICOLI
if I click again on gruppo_specie I can see the following 10 rows:
?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
codice descrizione gruppo_specie
------ --------------------- -------------
0126 Equidi
01 Pesce d'acqua dolce
0142 Colombo
0131 Gallus Gallus
I Carni di ungulati domestici
III Carni di selvaggina allevata
IV Carni di selvaggina cacciata
VI Prodotti a base di carne
VII Molluschi bivalvi vivi
VIII Prodotti della pesca
I tried this sort in PostgreSQL and it is different from paginate:
sfera_tg11=# select
specie.codice,specie.descrizione,gruppo_specie.descrizione from specie
left join gruppo_specie on
specie.cod_gruppo_specie=gruppo_specie.codice order by
cod_gruppo_specie DESC limit 10;
codice | descrizione | descrizione
--------+------------------------------+-------------
01 | Pesce d'acqua dolce |
0142 | Colombo |
0131 | Gallus Gallus |
I | Carni di ungulati domestici |
III | Carni di selvaggina allevata |
IV | Carni di selvaggina cacciata |
VI | Prodotti a base di carne |
VII | Molluschi bivalvi vivi |
VIII | Prodotti della pesca |
0126 | Equidi |
(10 rows)
sfera_tg11=# select
specie.codice,specie.descrizione,gruppo_specie.descrizione from specie
left join gruppo_specie on
specie.cod_gruppo_specie=gruppo_specie.codice order by
cod_gruppo_specie ASC limit 10;
codice | descrizione | descrizione
--------+-------------+-------------------
0129 | Bufalino | BOVINI E BUFALINI
0121 | Bovino | BOVINI E BUFALINI
0122 | Suino | SUIDI
0125 | Caprino | OVINI E CAPRINI
0124 | Ovino | OVINI E CAPRINI
0133 | Pernice | AVICOLI
0139 | Fagiano | AVICOLI
0134 | Quaglie | AVICOLI
0136 | Piccione | AVICOLI
0137 | Oca | AVICOLI
(10 rows)
--
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.