Sorry, Massimo, I am writing toooo much.
Just do waht you want, if it is your use-case, just go !

Nevertheless, here are again my remarks:

Am 24.04.2013 15:12, schrieb Massimo Manghi:
> On 04/24/2013 02:01 PM, Harald Oehlmann wrote:
>>
>> Well, my baby ;-)
>> I just fixed bugs and security holes...
>>
> 
> the same for me about Rivet, still I consider it my baby after almost 6
> years...

At least, you have human babies too ;-)

> I have select inputs whose data are built from queries to a database.
> In the whole picture it would be nice if also the database interface
> could be able to return a dictionary. It doesn't change the basic facts
> about form, just provides a nice interface for passing parameters by
> value in a single object while keeping coherent the way they're handled
> in the code
> 
> select wn \
>  -dictionary [$dbobj dictionary "select key,value from table where..."]

so this replaces:
set d [$dbobj dictionary "select key,value from table where..."]
$f select wm -labels [dict keys $d] -values [dict values $d]

This is reasonable.

In this case, I would not call the parameter "-dictionary". I would
suggest by the name that it sets labels and values at the same time.
Anyway, it is not important, that it is a dictionary, for the outside,
it may be a list with alternating key,val pairs.

What about:
$f select wn \
    -vallabels [$dbobj dictionary "select key,value from table where..."]

I am not shure how "$dbobj dictionary" works, but IMHO the "values"
should be the dict keys and the "labels" should be the dict values.
But I am not shure on this.

Internally in the form package, I would not handle the -vallabels
parameter as a dict, but as a list.
There might be multiple labels with same values and multiple values with
same labels, no uniqueness in no direction.

The caller may decide to pass a dict.

As an extreme, we may propose for dicts:
$f select win -vallabels $d1
and
$f select win -labvalues $d2

In the first, the dict keys are the values, in the second they are the
labels.

------
Side note about data bases: I would prefer to get close to the format
given by tdbc. When "dict" is used as output, you get by
set ld [$db allrows -type dict "select key,val from table where..."]
This results in a list of dicts like that:
{key K1 val V1} {key K2 val V2}

------
Enjoy,
Harald

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to