Re: Some questions about file handling + some other things

Ralf Schlatterbeck <[email protected]>
Newsgroups gmane.comp.bug-tracking.roundup.user
Message-ID <[email protected]>
On Wed, Mar 24, 2021 at 11:05:19AM -0400, John P. Rouillard wrote:
> >> context.files.sorted('filetype'), when the 'files' list had an item
> >> with 'filetype' unset.
> >
> >Sorting by Multilink happens in Python not in SQL. What is your use-case
> >for sorting by Multilink? In my experience the sort order created by
> >this is hardly understandable by humans.
> 
> I don't think this is sorting by multilink but sorting the items in a
> multilink. At least thats how I read cgi/templating.py:
> MultilinkHTMLProperty::sorted().

Yep, if this is the only use in current templates this is fine.

> >I would like to deprecate its use.

Note that you *can* sort by Multilinks, there is currently even a
regression test for this.

> IIRC there was either a bug report or email thread about sorting by
> multilinks (as opposed to sorting the elements of a multilink). The
> original design doc calls for sorting by len(multilink) IIRC. I don't
> know what sorting by the multilink prop does currently.

OK, currently its implemented as follows:
- Sort each individual multilink property by its order property
- sort the resulting list of lists

Hardly understandable by humans because if certain lists miss certain
items, the sort order will be completely different.

> I'll have to see if I cand dredge it up. IIRC we came up with a use
> case for this which was saner than the current sorting method.

that would be fine.

> >I also at one time wanted to implement key properties with multiple
> >values: An application often demands uniqueness over several properties
> >not just one. I discussed this *many* years ago with Richard but he
> >feared at the time that things would be complicated by this. I still
> >think it would be a useful feature.
> 
> I would tend to agree it's useful. Maybe a key() function that is
> passed the item? Could be materialized in a _key hidden/reserved
> property name similar to creator/activity....

We already have setkey. This could be enhanced to optionally take a
list. Similar for labelprop and orderprop (which default to the key
property if there is one). The *do* have separate set methods where you
can set a labelprop and/or orderprop, these could be enhanced in a
similar fashion.

Note that once a labelprop can take multiple properties it is unclear
how this should be displayed.

> >> Second try: I do two database query for tasks (the first
> >> one filters on 'deadline is set', and an other one filters on 'deadline
> >> is not set', and join these list.
> >
> >Yes, this can be done in an explicit index template if you really need
> >that behavior.
> 
> Do you have an example? I envision some sort of concatenation of id's
> that result from a search that are sent into request/batch somehow.

Ouch: I didn't think about batches. So far I've used only special pages
without batches. And I don't think you can force a different ordering by
giving IDs or something. So it may well be that this is currently not
possible with batches.

Ralf
-- 
Dr. Ralf Schlatterbeck                  Tel:   +43/2243/26465-16
Open Source Consulting                  www:   www.runtux.com
Reichergasse 131, A-3411 Weidling       email: [email protected]
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.