sorting in your locale

View: New views
2 Messages — Rating Filter:   Alert me  

sorting in your locale

by Benny Malengier :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Peter,

can you try something about your local sort order of linux as opposed
to windows.

In flatbasemodel.py, I see that the sort is with:

 return sorted( (conv_unicode_tosrtkey_ongtk(self.sort_func(data)),
                            key) for key, data in cursor )

However, when you insert a value, the code is:
insert_val = (locale.strxfrm(self.sort_func(data)), handle)

So, this is different on windows, as conv_unicode_tosrtkey_ongtk does
something else on windows to resolve the problem you had on windows.

So can you in the event/source or noteview add objects (in windows)
and see if they are added in the correct position? Then if by clicking
on the column headers the position is not changing?

The solution would be to change locale.strxfrm everywhere by a call to
conv_unicode_tosrtkey_ongtk
I am now working on the patch of Nick in peopleview, so I need to do
there the same thing to obtain correct results.

Benny

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Gramps-devel mailing list
Gramps-devel@...
https://lists.sourceforge.net/lists/listinfo/gramps-devel

Parent Message unknown Re: sorting in your locale

by Benny Malengier :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Peter, can you try again after rev 13520, only one way of converting
sortkeys is used now, so at least it should be consistent.

Please, try the delete also, it is important that on delete we find
via a bisect search the correct position where the key is.

Benny

2009/11/6 Peter Landgren <peter.talken@...>:

> Benny,
> Yes I remember.
> I upgraded my Windows trunk to r 13503.
> First a comment on importing. I XML-imported my current database. It took almost an hour on my
> Windows box, while on my Linux it took 3 minutes!
>
> I run the test with Swedish locale and with Gramps with Swedish.
>
> For the test I created a new Family Tree with one person with six notes beginning with
> A, B, C, Å, Ä and Ö. And that looked OK in the notes view.
> Added one note beginning with Y: Result:  ABCYÅÄÖ OK
> Added one note beginning with Ö: Result: AÖBCYÅÄÖ not OK
> Added one note beginning with Ä: Result: ÄAÖBCYÅÄÖ not OK
> Added one note beginning with Å: Result: ÄÅAÖBCYÅÄÖ not OK
> Next I pressed the column header for the preview several times: still the same bad order.
> Next I pressed the column header for the ID and then the column header for the preview: Now the
> order is OK. I can press the column header for the preview several times and it's still OK.
>
> Did this twice to be sure.
> If I add a note in the person editor the note view sort is OK.
>
> Another comment:
> When I first tried this I used my new imported database and under Notes I got an error:
>
> : ERROR .: Unhandled exception
> Traceback (most recent call last):
>  File "C:\Program\gramps320\gui\viewmanager.py", line 1012, in change_page
>    self.__do_change_page(num)
>  File "C:\Program\gramps320\gui\viewmanager.py", line 1031, in __do_change_page
>    self.active_page.set_active()
>  File "C:\Program\gramps320\gui\views\navigationview.py", line 124, in set_active
>    PageView.set_active(self)
>  File "C:\Program\gramps320\gui\views\pageview.py", line 112, in set_active
>    self.build_tree()
>  File "C:\Program\gramps320\gui\views\listview.py", line 230, in build_tree
>    sort_map=self.column_order())
>  File "C:\Program\gramps320\DisplayModels\_NoteModel.py", line 76, in __init__
>    skip=skip, sort_map=sort_map)
>  File "C:\Program\gramps320\gui\views\treemodels\flatbasemodel.py", line 408, in __init__
>    self.rebuild_data()
>  File "C:\Program\gramps320\gui\views\treemodels\flatbasemodel.py", line 514, in _rebuild_search
>    allkeys = self.sort_keys()
>  File "C:\Program\gramps320\gui\views\treemodels\flatbasemodel.py", line 505, in sort_keys
>    key) for key, data in cursor )
>  File "C:\Program\gramps320\gui\views\treemodels\flatbasemodel.py", line 505, in <genexpr>
>    key) for key, data in cursor )
>  File "C:\Program\gramps320\Utils.py", line 282, in <lambda>
>    conv_unicode_tosrtkey_ongtk = lambda x: locale.strxfrm(x.encode(codeset))
>  File "C:\Python26\lib\encodings\cp1252.py", line 12, in encode
>    return codecs.charmap_encode(input,errors,encoding_table)
> UnicodeEncodeError: 'charmap' codec can't encode character u'\u0144' in position 14: character maps
> to <undefined>
>
> I fond the culprit: I had in a note two characters "ǹ", which caused this error in Windows. No
> errors in Linux. I could go to person view and edit the person with that note, which was shown
> correctly. Changed "ǹ" to "n" and all worked without problem. So there might be some code conversion
> problems in Windows?
>
> /Peter
>
>> 2009/11/6 Peter Landgren <peter.talken@...>:
>> > Just to be sure, this is for trunk?
>>
>> Yes. If you remember, sorting broke after my changes to the views for
>> you on windows.
>> These changes will now be also done in the person view.
>>
>> Benny
>>
>> > /Peter
>> >
>> >> Peter,
>> >>
>> >> can you try something about your local sort order of linux as opposed
>> >> to windows.
>> >>
>> >> In flatbasemodel.py, I see that the sort is with:
>> >>
>> >>  return sorted( (conv_unicode_tosrtkey_ongtk(self.sort_func(data)),
>> >>                             key) for key, data in cursor )
>> >>
>> >> However, when you insert a value, the code is:
>> >> insert_val = (locale.strxfrm(self.sort_func(data)), handle)
>> >>
>> >> So, this is different on windows, as conv_unicode_tosrtkey_ongtk does
>> >> something else on windows to resolve the problem you had on windows.
>> >>
>> >> So can you in the event/source or noteview add objects (in windows)
>> >> and see if they are added in the correct position? Then if by clicking
>> >> on the column headers the position is not changing?
>> >>
>> >> The solution would be to change locale.strxfrm everywhere by a call to
>> >> conv_unicode_tosrtkey_ongtk
>> >> I am now working on the patch of Nick in peopleview, so I need to do
>> >> there the same thing to obtain correct results.
>> >>
>> >> Benny
>
>

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Gramps-devel mailing list
Gramps-devel@...
https://lists.sourceforge.net/lists/listinfo/gramps-devel