Thread: [Rest2web-develop] problem with sort order of sections variable
Brought to you by:
mjfoord
From: martin f k. <ma...@ma...> - 2006-11-08 13:46:34
|
Hi there, The sections variable is an OrderedDict. I am, however, confused as to how it's ordered. I have files 1-6.txt (so 1.txt, 2.txt, ..., 6.txt), and they have titles with starting letters G,R,K,P,S,V respectively. Yet, when I iterate sections, the order I get is 4,1,2,3,6,5 (P,G,R,K,V,S). So I guess neither filename nor title actually play a role. How can I then influence the sort order of the sections variable, which is used e.g. by minibar. Cheers, --=20 martin; (greetings from the heart of the sun.) \____ echo mailto: !#^."<*>"|tr "<*> mailto:" net@madduck =20 spamtraps: mad...@ma... =20 fighting for peace is like screwing for virginity. -- the irish times, washington dc |
From: martin f k. <ma...@ma...> - 2006-11-08 13:56:14
|
also sprach martin f krafft <ma...@ma...> [2006.11.08.1446 +0100]: > How can I then influence the sort order of the sections variable, > which is used e.g. by minibar. To sort by filename (=3D=3D target), I used the following hack, but there has to be a better way: <# def page_sorter(a, b): return cmp(a['target'], b['target']) sections[None]['pages'].sort(page_sorter) minibar(sections, intro=3D'', subsect=3DFalse) #> --=20 martin; (greetings from the heart of the sun.) \____ echo mailto: !#^."<*>"|tr "<*> mailto:" net@madduck =20 spamtraps: mad...@ma... =20 the best way to accelerate a computer running windoze is at 9.81 ms^-2 |
From: Michael F. <fuz...@vo...> - 2006-11-08 14:07:42
|
martin f krafft wrote: > Hi there, > > The sections variable is an OrderedDict. I am, however, confused as > to how it's ordered. I have files 1-6.txt (so 1.txt, 2.txt, ..., > 6.txt), and they have titles with starting letters G,R,K,P,S,V > respectively. Yet, when I iterate sections, the order I get is > 4,1,2,3,6,5 (P,G,R,K,V,S). So I guess neither filename nor title > actually play a role. > It *ought* to use the ordering you declare them in the restindex... Fuzzyman http://www.voidspace.org.uk/index2.shtml > How can I then influence the sort order of the sections variable, > which is used e.g. by minibar. > > Cheers, > > > ------------------------------------------------------------------------ > > ------------------------------------------------------------------------- > Using Tomcat but need to do more? Need to support web services, security? > Get stuff done quickly with pre-integrated technology to make your job easier > Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo > http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 > ------------------------------------------------------------------------ > > _______________________________________________ > Rest2web-develop mailing list > Res...@li... > https://lists.sourceforge.net/lists/listinfo/rest2web-develop > |
From: Michael F. <fuz...@vo...> - 2006-11-08 14:13:34
|
Michael Foord wrote: > martin f krafft wrote: > >> Hi there, >> >> The sections variable is an OrderedDict. I am, however, confused as >> to how it's ordered. I have files 1-6.txt (so 1.txt, 2.txt, ..., >> 6.txt), and they have titles with starting letters G,R,K,P,S,V >> respectively. Yet, when I iterate sections, the order I get is >> 4,1,2,3,6,5 (P,G,R,K,V,S). So I guess neither filename nor title >> actually play a role. >> >> > It *ought* to use the ordering you declare them in the restindex... > > Sorry, I got confused. My answer was only partially helpful. You can explicitly specify an order for files within a section using the 'section-pages' keyword in the restindex. section-pages: section-name, page1, page2, page3 If you only use the default section within a directory then you can do : section-pages: , page1, page2, page3 (Extra leading comma to specify the default section ordering.) I use this feature a lot where I want to specify the order of pages - and it usually has little to do with page title or filename. Fuzzyman http://www.voidspace.org.uk/index2.shtml > Fuzzyman > http://www.voidspace.org.uk/index2.shtml > > >> How can I then influence the sort order of the sections variable, >> which is used e.g. by minibar. >> >> Cheers, >> >> >> ------------------------------------------------------------------------ >> >> ------------------------------------------------------------------------- >> Using Tomcat but need to do more? Need to support web services, security? >> Get stuff done quickly with pre-integrated technology to make your job easier >> Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo >> http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 >> ------------------------------------------------------------------------ >> >> _______________________________________________ >> Rest2web-develop mailing list >> Res...@li... >> https://lists.sourceforge.net/lists/listinfo/rest2web-develop >> >> > > > ------------------------------------------------------------------------- > Using Tomcat but need to do more? Need to support web services, security? > Get stuff done quickly with pre-integrated technology to make your job easier > Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo > http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 > _______________________________________________ > Rest2web-develop mailing list > Res...@li... > https://lists.sourceforge.net/lists/listinfo/rest2web-develop > > |
From: martin f k. <ma...@ma...> - 2006-11-08 14:18:42
|
also sprach Michael Foord <fuz...@vo...> [2006.11.08.1512 +010= 0]: > You can explicitly specify an order for files within a section using the= =20 > 'section-pages' keyword in the restindex. > =20 > section-pages: section-name, page1, page2, page3 >=20 > If you only use the default section within a directory then you can do : >=20 > section-pages: , page1, page2, page3=20 >=20 > (Extra leading comma to specify the default section ordering.) >=20 > I use this feature a lot where I want to specify the order of pages -=20 > and it usually has little to do with page title or filename. Well, in my case it does, and I *hate* "explicit". So there's no other way to make it sort by filename or title automatically? Cheers, --=20 martin; (greetings from the heart of the sun.) \____ echo mailto: !#^."<*>"|tr "<*> mailto:" net@madduck =20 spamtraps: mad...@ma... =20 "president thieu says he'll quit if he doesn't get more than 50% of the vote. in a democracy, that's not called quitting." -- the washington post |
From: Michael F. <fuz...@vo...> - 2006-11-08 15:22:21
|
martin f krafft wrote: > also sprach Michael Foord <fuz...@vo...> [2006.11.08.1512 +0100]: > >> You can explicitly specify an order for files within a section using the >> 'section-pages' keyword in the restindex. >> >> section-pages: section-name, page1, page2, page3 >> >> If you only use the default section within a directory then you can do : >> >> section-pages: , page1, page2, page3 >> >> (Extra leading comma to specify the default section ordering.) >> >> I use this feature a lot where I want to specify the order of pages - >> and it usually has little to do with page title or filename. >> > > Well, in my case it does, and I *hate* "explicit". So there's no > other way to make it sort by filename or title automatically? > Nope, no-one has ever asked for it before. What sort of interface would you like ? Fuzzyman http://www.voidspace.org.uk/index2.shtml > Cheers, > > > ------------------------------------------------------------------------ > > ------------------------------------------------------------------------- > Using Tomcat but need to do more? Need to support web services, security? > Get stuff done quickly with pre-integrated technology to make your job easier > Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo > http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 > ------------------------------------------------------------------------ > > _______________________________________________ > Rest2web-develop mailing list > Res...@li... > https://lists.sourceforge.net/lists/listinfo/rest2web-develop > |
From: martin f k. <ma...@ma...> - 2006-11-08 15:26:44
|
also sprach Michael Foord <fuz...@vo...> [2006.11.08.1621 +010= 0]: > Nope, no-one has ever asked for it before. What sort of interface would= =20 > you like ? How about the attribute name of the page variables, e.g. link-title? Alternatively, a function could be passed as comparator. using callable(), you can easily distinguish between the two. :) --=20 martin; (greetings from the heart of the sun.) \____ echo mailto: !#^."<*>"|tr "<*> mailto:" net@madduck =20 spamtraps: mad...@ma... =20 "she is absolutely inadmissible into society. many a woman has a past, but I am told that she has at least a dozen, and that they all fit." -- oscar wilde |
From: Gael V. <gae...@no...> - 2006-11-08 15:38:52
|
On Wed, Nov 08, 2006 at 04:26:27PM +0100, martin f krafft wrote: > also sprach Michael Foord <fuz...@vo...> [2006.11.08.1621 = +0100]: > > Nope, no-one has ever asked for it before. What sort of interface wou= ld=20 > > you like ? > How about the attribute name of the page variables, e.g. link-title? > Alternatively, a function could be passed as comparator. using > callable(), you can easily distinguish between the two. :) +1 ! I would like to use userdata on my pages that happen to be the date. You can keep this use case in mind if you are going to create an interface. --=20 Ga=EBl |
From: Michael F. <ar...@vo...> - 2006-11-20 00:13:21
|
martin f krafft wrote: > also sprach Michael Foord <fuz...@vo...> [2006.11.08.1621 +0100]: > >> Nope, no-one has ever asked for it before. What sort of interface would >> you like ? >> > > How about the attribute name of the page variables, e.g. link-title? > > Alternatively, a function could be passed as comparator. using > callable(), you can easily distinguish between the two. :) > Right. 'sections' is an ordered dictionary, ordered by the *sections*. Each section. The 'pages' entry of each section is a list of dictionaries representing each page. This is what we want to order. So the 'sort' method of 'sections' is used to sort the sections, not the pages. What I have done is implemented a new method for 'sections': 'sortpages' This is now in subversion. Docs below. ``sections`` has a method for sorting the pages contained in all the section dictionaries. By default the pages are sorted according to the ``section-pages`` in the restindex. If you don't use section-pages, the ordering is arbitrary. The ``sortpages`` method allows you to sort the pages by ``link-title`` (alphabetical) or pass in a custom function to do the sorting. (The same sort of function you would pass to the Python ``sort`` method of lists.) sections.sortpages(sortorder, section=True) ``sortorder`` can either be the string ``link-title`` or a custom function. By default, calling ``sortpages`` will sort all the sections. Alternatively you can pass in a string (or None), to specify which section to sort. What I haven't done yet is tested this. I'm part way through creating a test case and will probably complete it tomorrow. Comments and bug reports welcomed. :-) Michael http://www.voidspace.org.uk/index2.shtml -- No virus found in this outgoing message. Checked by AVG Free Edition. Version: 7.1.409 / Virus Database: 268.14.7/538 - Release Date: 18/11/2006 |
From: martin f k. <ma...@ma...> - 2006-11-08 14:17:44
|
also sprach Michael Foord <fuz...@vo...> [2006.11.08.1507 +010= 0]: > It *ought* to use the ordering you declare them in the restindex... Well, I am not doing anything in restindex. All the pages I want in the minibar are in a subdirectory. There's no sectionlist or section-pages anywhere, meaning that sections only has one item: sections[None]. I actually care about the sorting of sections[None]['pages']. --=20 martin; (greetings from the heart of the sun.) \____ echo mailto: !#^."<*>"|tr "<*> mailto:" net@madduck =20 spamtraps: mad...@ma... =20 "if ever somethin' don't feel right to you, remember what pancho said to the cisco kid... `let's win, before we are dancing at the end of a rope, without music.'" -- sailor |
From: Michael F. <ar...@vo...> - 2006-11-08 22:39:27
|
martin f krafft wrote: > also sprach Michael Foord <fuz...@vo...> [2006.11.08.1621 +0100]: > >> Nope, no-one has ever asked for it before. What sort of interface would >> you like ? >> > > How about the attribute name of the page variables, e.g. link-title? > > Alternatively, a function could be passed as comparator. using > callable(), you can easily distinguish between the two. :) > Ok, I'll work on this for the next release. Fuzzyman http://www.voidspace.org.uk/index2.shtml > > ------------------------------------------------------------------------ > > ------------------------------------------------------------------------- > Using Tomcat but need to do more? Need to support web services, security? > Get stuff done quickly with pre-integrated technology to make your job easier > Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo > http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 > ------------------------------------------------------------------------ > > _______________________________________________ > Rest2web-develop mailing list > Res...@li... > https://lists.sourceforge.net/lists/listinfo/rest2web-develop > -- No virus found in this outgoing message. Checked by AVG Free Edition. Version: 7.1.409 / Virus Database: 268.13.32/523 - Release Date: 07/11/2006 |
From: martin f k. <ma...@ma...> - 2006-11-08 22:57:43
|
also sprach Michael Foord <ar...@vo...> [2006.11.08.2338 +0100= ]: > Ok, I'll work on this for the next release. You are seriously competing for being my favourite upstream, huh? :) --=20 martin; (greetings from the heart of the sun.) \____ echo mailto: !#^."<*>"|tr "<*> mailto:" net@madduck =20 spamtraps: mad...@ma... =20 an egg has the shortest sex-life of all: if gets laid once; it gets eaten once. it also has to come in a box with 11 others, and the only person who will sit on its face is its mother. |