xo::REST method body (protected)
<instance of xo::REST> body [ -content_type content_type ] \ [ -vars vars ]
Defined in packages/xooauth/tcl/rest-procs.tcl
Build a body based on the provided variable names. The values are retrieved via uplevel calls.
- Switches:
- -content_type (optional, defaults to
"application/json; charset=utf-8"
)- -vars (optional)
- Testcases:
- No testcase defined.
Source code: # # Get the caller of the caller (and ignore next calling levels). # set callinglevel [:uplevel [current callinglevel] [list current callinglevel]] #ns_log notice "CURRENT CALLING LEVEL $callinglevel " [:uplevel $callinglevel [list info vars]] [:uplevel $callinglevel [list info level 0]] #foreach level {2 3} { # set cmd [lindex [:uplevel $level [list info level 0]] 0] # ns_log notice "$cmd check for vars '$vars' on level $level, have: [:uplevel $level [list info vars]]" # if {$cmd ne ":request"} break #} if {[string match "application/json*" $content_type]} { # # Convert var bindings to a JSON structure. This supports # an interface somewhat similar to export_vars but # supports currently as import just a list of variable # names with a suffix of either "array" (when value is a # list) or "triples" (for processing a triple list as # returned by e.g. mongo::json::parse). # return [:typed_list_to_json [concat {*}[lmap p $vars { if {[regexp {^(.*):([a-z]+)(,[a-z]+)?$} $p . prefix suffix type]} { set type [expr {$type eq "" ? "string" : [string range $type 1 end]}] if {$suffix eq "array"} { set values [:uplevel $callinglevel [list set $prefix]] set result {}; set c 0 foreach v $values { lappend result [list [incr c] $type $v] } list $prefix array [concat {*}$result] } else { list $prefix $suffix [:uplevel $callinglevel [list set $prefix]] } } else { if {![:uplevel $callinglevel [list info exists $p]]} continue list $p string [:uplevel $callinglevel [list set $p]] } }]]] } else { return [:uplevel $callinglevel [list export_vars $vars]] }XQL Not present: Generic, PostgreSQL, Oracle