On 10/3/07, Massimo Manghi <[EMAIL PROTECTED]> wrote:
>
> Cristian wrote:
> > Hi,
> > I see that the actual implementation of load_response.tcl produces a
> > increasingly nested list when parsing multiple values for a given key.
> > I've corrected this by changing it to use concat instead of list (diff
> > attached to be run in rivet/rivet-tcl/). I also saw that no test files
> > were present for this command, so I wrote them too (attached
> > load_response.rvt and load_response.test to be copied in tests/).
>
> the load_response problem was discussed last February.
> IIRC David explained that changing this function in
> that way would have some side effects in case
> list valued parameters are passed to the server (see the
> list archives).
>
>
Hi massimo,
I finaly found the archives by googling for rivet-dev and archive. It is
even searchable! Will check there in the future before posting...
So if I understand it correctly, wouldn't the following solve the problem?

proc load_response {{arrayName response}} {
    upvar 1 $arrayName response

    array set response {}

    foreach {var elem} [var all] {
        if {[info exists response($var)]} {
            set response($var) [lappend response($var) [list $elem]]
        } else {
            set response($var) [list $elem]
        }
    }
}

file load_response_test.rvt:
---
load_response
if { [ array exists response ] } {
    foreach { ck } [ array names response ]  {
        puts "response($ck) = $response($ck)\n"
    }
}
---

which for a
http://localhost:8081/load_response_test.rvt?foo=bar+baz&fee=bat&foo=bak

produces:
response(fee) = bat
response(foo) = {bar baz} bak

Or will the load_response proc be deleted from the sources?

Cristian

Reply via email to