ad_ns_set_to_tcl_vars (public, deprecated)

 ad_ns_set_to_tcl_vars [ -duplicates duplicates ] [ -level level ] \
    set_id

Defined in packages/acs-tcl/tcl/utilities-procs.tcl

Deprecated. Invoking this procedure generates a warning.

Takes an ns_set and sets variables in the caller's environment correspondingly, i.e. if key is foo and value is bar, the Tcl var foo is set to bar. DEPRECATED: the few remaining usages of this API in upstream code were found to be easily replaceable with much saner and clearer idioms.

Switches:
-duplicates
(defaults to "overwrite") (optional)
This optional switch argument defines what happens if the Tcl var already exists, or if there are duplicate entries for the same key. overwrites just overwrites the var, which amounts to letting the ns_set win over pre-defined vars, and later entries in the ns_set win over earlier ones. ignore means the variable isn't overwritten. fail will make this proc fail with an error. This makes it easier to track subtle errors that could occur because of unpredicted name clashes.
-level
(defaults to "1") (optional)
The level to upvar to.
Parameters:
set_id
Author:
Lars Pind <lars@pinds.com>
See Also:
  • upvar
  • for
  • ns_set

Partial Call Graph (max 5 caller/called nodes):
%3 ad_user_class_description ad_user_class_description (public, deprecated) ad_ns_set_to_tcl_vars ad_ns_set_to_tcl_vars ad_user_class_description->ad_ns_set_to_tcl_vars ad_log_deprecated ad_log_deprecated (public) ad_ns_set_to_tcl_vars->ad_log_deprecated

Testcases:
No testcase defined.
Source code:
ad_log_deprecated proc ad_ns_set_to_tcl_vars
    if { $duplicates ni {ignore fail overwrite} } {
        return -code error "The optional switch duplicates must be either overwrite, ignore or fail"
    }

    foreach {varname value} [ns_set array $set_id] {
        upvar $level $varname var
        if { [info exists var] } {
            switch -- $duplicates {
                fail {
                    return -code error "ad_ns_set_to_tcl_vars tried to set the var $varname which is already set"
                }
                ignore {
                    # it's already set ... don't overwrite it
                    continue
                }
            }
        }
        set var $value
    }
XQL Not present:
PostgreSQL, Oracle
Generic XQL file:
packages/acs-tcl/tcl/utilities-procs.xql

[ hide source ] | [ make this the default ]
Show another procedure: