Valerio Gionco <[EMAIL PROTECTED]> writes:
> the current code in mod_dtcl is:
>
> /* take results and create tcl variables from them */
> if (req->parms)
> {
> int i;
> array_header *parmsarray = ap_table_elts(req->parms);
> table_entry *parms = (table_entry *)parmsarray->elts;
> Tcl_Obj *varsobj = Tcl_NewStringObj("::request::VARS", -1);
> for (i = 0; i < parmsarray->nelts; ++i)
> {
> if (!parms[i].key)
> continue;
>
> Tcl_ObjSetVar2(interp, varsobj,
> STRING_TO_UTF_TO_OBJ(parms[i].key),
> STRING_TO_UTF_TO_OBJ(parms[i].val),
> 0);
> }
>
> }
> I'm not an Apache API expert, but looks like all what you have is
> the number of the defined keys (in parmsarray->nelts) and an array
> parmsarray->elts of name-value couples.
This actually doesn't come straight from Apache, but from libapreq,
which I have directly included as the apache_* files.
> > Actually, I'm using mod_dtcl for almost a year and I've never sent
> > multiple checkboxes with the same name. I'm using NAME=prefix_name
> > and then array names VARS prefix_*. Didn't benchmark that one, but
> > shouldn't be that slow...
I don't think it's that rare... I faced this problem the other day.
[ changing names to foo[] ]
> This would be a big pain for us, since we are porting a (big!!) set
> of CGI scripts with an internal API, and changing the names of all
> those checkboxes is out of question. My boss would probably kill
> me. :-)
I don't really like their solution in any case, but I am getting the
feeling that a hack of some type is just unavoidable.
> My priorities are:
>
> - Being able to retrieve all variables :)
>
> - Having a consistent way to do it
>
> - ok, the performance is important, too...
> For my purposes a key-value list would be a great thing; other
> methods to access a single variable could be useful but not
> mandatory; I'd probably end not using them, anyway.
If you know that a variable could be a list, you check LVARS(name),
and if it exists, then you can be sure that VARS(name) is a list, and
not a string beginning with {.
Does that sound fair? That was your original suggestion as I
understood it the other day, it is easy to implement, and it isn't
*too* awfully wierd.
The only other thing that seems acceptable is a command, but that is
slower, and will require reworking of existing scripts. And in any
case, you still have to know when your variable might be a list:
set lst [ vars get -list foo ]
It is cleaner though, more flexible, and also extensible.
--
David N. Welton
Free Software: http://people.debian.org/~davidw/
Apache Tcl: http://tcl.apache.org/
Personal: http://www.efn.org/~davidw/
Work: http://www.innominate.com/
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]