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 12:55:12AM +0100, Nagy Gabor wrote:
> One more question on Dates. The dates must be submitted in
> html form variables in the standard date format 2021-03-24.14:00,
> right? There are methods for printing dates in alternative format (like
> pretty()), but it seems to me that the date submitted to Roundup must
> be in this format. And I guess if my users want a different date format,
> then I have to do the conversions on my own.

You can also enter dates in the extended format that allows for
arithmetics on dates, e.g.

.
.+5w
.-3y

would all be valid dates to enter in the date field.

> And some additional comments I've run into this weekend:
> 
> The sorted method of Multilink properties (provided by the cgi engine),
> does not always work as expected. First, I got Python error on
> 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 would like to deprecate its use.

> Second, this method does not seem to respect the data type of the
> 'order' property of 'filetype' class.

This is definitely worth a bug-report, especially if this also applies
to sorting by non-multilinks.
I *think* we currently allow only strings as key- order- and label
properties. This should probably change.

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.

> It was set to Integer in my
> schema.py for the 'filetype' class, but sorted() treated it as a string.
> It took a while until I realised that the reason for unexpected sorting
> is "12" < "2", for example. :)
Ouch :-)

> Finally, one more minor question. Assume that I want to sort notclosed
> tasks by 'deadline' in increasing order (which seems reasonable). In
> this case the first tasks will be those for which deadline is unset.

Yes, this happened more-or-less accidentally: It is the default order of
mysql and was correctly covered by the regression tests, so sorting them
in front is explicitly done in the generated sql for other backends.

> But what if I want to put them to the end of the list? How this can be
> done?

You currently cannot change the way things are sorted (Except for the
sort direction).

> (First try: I won't allow unset deadline, it is 9999-12-31 behind
> the scenes.

Yes, this is a sensible choice if your application allows it.
You can code an auditor that sets the date to some default value if the
user didn't supply one.

> 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.

> But this is just an example, I am more interested in how these
> filter/sort cgi request can be customized, or the obtained "batch
> list" modified?)

Currently you cannot customize how individual properties that are
included in sort and/or group are sorted, except for reverse/forward.

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.