Forum OpenACS Development: Re: passing arguments, ad_proc definitions

Collapse
Posted by Torben Brosten on
If I understand correctly, get_opts is passing a list of named parameters out of a procedure's namespace, to the namespace that called the procedure.

I'm looking to pass an unspecified set of named parameters that is provided with a call, to the namespace within the procedure. For example:

qf_test -foo value1 -bar value2 -fooo valueN -barr valueM

Based on get_opts and your answer, I'm going to assume my question isn't an option to be defined via ad_proc, and that I should use upvar instead. This makes sense, since extra care needs to be taken so that any named parameter that is passed does not interfere with the code in some sort of unplanned value injection method etc.

Thank you,

Torben

Collapse
Posted by Dave Bauer on
Look at how template::element::create works.

It takes any arbitrary named arguments and passes them on to the element definition since element::create is used for every widget etc, and widgets have various different arguments.

So if you call

element::create -one 1 -two 2

then when get_opts is called withing element::create there is an array within the scope of element::create called opts that contains {one 1 two 2}

I am pretty sure it does exactly what you want.