- Methods: All Methods Documented Methods Hide Methods
- Source: Display Source Hide Source
- Variables: Show Variables Hide Variables
Class ::xo::Context
::xo::Context create ... \
[ -actual_query (default " ") ] \
[ -invoke_object invoke_object ] \
[ -locale locale ] \
[ -package_id (default "0") ] \
[ -parameter_declaration (default "") ]
Defined in
Class Relations
- class: ::xotcl::Class
- superclass: ::xotcl::Object
- subclass: ::xowiki::Includelet, ::xo::ConnectionContext
::xotcl::Class create ::xo::Context \ -superclass ::xotcl::ObjectMethods (to be applied on instances)
exists_query_parameter (scripted)
<instance of xo::Context> exists_query_parameter
- Testcases:
- test_xo_cc, xotcl-core
#:log "--qp exists $name => [info exists :queryparm($name)]" info exists :queryparm($name)export_vars (scripted, public)
<instance of xo::Context> export_vars [ -all ] [ -level level ]Export either the declared query variables (default) or all (when explicitly demanded).
- Switches:
- -all (optional)
- when specified, export all query variables
- -level (optional, defaults to
"1"
)- target level
- Testcases:
- package_normalize_path, xowiki_test_cases, link_tests, slot_interactions, path_resolve
if {$all} { foreach p [array names :queryparm] { regsub -all : $p _ varName uplevel $level [list set $varName [set :queryparm($p)]] } } else { # # Export only declared parameters (coming from the package # initialization or from the includelet definition). # foreach p [array names :queryparm] { if {$p in ${:declared_parameters}} { #ns_log notice "=== export <$p>" uplevel $level [list set $p [set :queryparm($p)]] } } } # # Set always variable package_id # uplevel $level [list set package_id ${:package_id}]get_parameters (scripted, public)
<instance of xo::Context> get_parametersConvenience routine for includelets. It combines the actual parameters from the call in the page (highest priority) with the values from the url (second priority) and the default values from the signature.
- Testcases:
- xowiki_test_cases
set source [expr {[info exists :__caller_parameters] ? [self] : [:info parent]}] $source instvar __caller_parameters #set n [expr {[info exists :name] ? ${:name} : "NONE"}] #ns_log notice "$n: GET PARAMETERS source <$source> have [info exists __caller_parameters]" if {![info exists :__including_page]} { # # An includelet is called from the top-level. The actual_query # might be cached, so we reset it here. # set :actual_query [::xo::cc actual_query] } if {[info exists __caller_parameters]} { :process_query_parameter -all_from_query false -caller_parameters $__caller_parameters } else { :process_query_parameter -all_from_query false } :export_vars -level 2invoke_object (setter)
<instance of xo::Context> invoke_objectoriginal_url_and_query (scripted)
<instance of xo::Context> original_url_and_query
- Testcases:
- package_normalize_path, xowiki, xowiki_test_cases, link_tests, slot_interactions, path_resolve
if {[llength $args] == 1} { set :original_url_and_query [lindex $args 0] } elseif {[info exists :original_url_and_query]} { return ${:original_url_and_query} } else { return ${:url}?${:actual_query} }package_id (setter)
<instance of xo::Context> package_id
- Testcases:
- xotcl_core_tutorial_2, xotcl-core, xowiki_test_cases, link_tests
process_query_parameter (scripted)
<instance of xo::Context> process_query_parameter
- Testcases:
- api__context, xotcl-core
set declared_parameters [lmap v ${:parameter_declaration} { string range [lindex [split [lindex $v 0] :] 0] 1 end }] if {${:actual_query} eq " "} { if {[ns_conn isconnected]} { set :actual_query [ns_conn query] } #:log "--P actual_query <${:actual_query}> url [ns_conn url] q [ns_conn query]" } set passed_args "" #:log "--P processing actual query '${:actual_query}'" try { set paramset [ns_parsequery ${:actual_query}] foreach {att_name att_value} [ns_set array $paramset] { if {$att_name eq ""} continue if {$att_name in $declared_parameters} { dict lappend passed_args -$att_name $att_value } elseif {$all_from_query} { set :queryparm($att_name) $att_value } } } on error {errorMsg} { ad_log warning "process_query_parameter: $errorMsg" ad_return_complaint 1 "invalid characters in HTTP query parameters" } # get the query parameters (from the form if necessary) if {[:istype ::xo::ConnectionContext]} { foreach name $declared_parameters { set param -$name #:log "--cc check $param [dict exists $passed_args $param]" if {![dict exists $passed_args $param] && [:exists_form_parameter $name] } { #:log "--cc adding passed_args(-$name) [:form_parameter $name]" dict set passed_args $param [:form_parameter $name] } } } # get the caller parameters (e.g. from the includelet call) if {[info exists caller_parameters]} { #:log "--cc caller_parameters=$caller_parameters" foreach param [dict keys $caller_parameters] { set name [string range $param 1 end] if {$name in $declared_parameters} { dict set passed_args $param [dict get $caller_parameters $param] } elseif {$all_from_caller} { set :queryparm($name) [dict get $caller_parameters $param] lappend declared_parameters $name } } } if {[::acs::icanuse "nsf::parseargs -asdict"]} { # OLD {64.347249 microseconds per iteration} # NEW {17.132942 microseconds per iteration} try { foreach {k v} [nsf::parseargs -asdict ${:parameter_declaration} $passed_args] { set :queryparm($k) $v } } on error {errorMsg} { ad_return_complaint 1 [ns_quotehtml $errorMsg] ad_script_abort } } else { #:log "--cc calling parser eval [self] __parse <${:parameter_declaration}> <$passed_args>" :proc __parse ${:parameter_declaration} { foreach v [info vars] { :log "--cc uplevel [list set :queryparm($v) [set $v]]" uplevel [list set :queryparm($v) [set $v]] } } if {[catch {[self] __parse {*}$passed_args} errorMsg]} { ad_return_complaint 1 [ns_quotehtml $errorMsg] ad_script_abort } } set :declared_parameters $declared_parameters #:log "--cc qp [array get :queryparm] // ${:actual_query}"
- Methods: All Methods Documented Methods Hide Methods
- Source: Display Source Hide Source
- Variables: Show Variables Hide Variables