xo::Context instproc process_query_parameter

 <instance of xo::Context[i]> process_query_parameter

Defined in

Partial Call Graph (max 5 caller/called nodes):
%3 test_api__context api__context (test ) xo::Context instproc process_query_parameter xo::Context instproc process_query_parameter test_api__context->xo::Context instproc process_query_parameter test_xotcl-core xotcl-core (test ) test_xotcl-core->xo::Context instproc process_query_parameter acs::icanuse acs::icanuse (public) xo::Context instproc process_query_parameter->acs::icanuse ad_log ad_log (public) xo::Context instproc process_query_parameter->ad_log ad_return_complaint ad_return_complaint (public) xo::Context instproc process_query_parameter->ad_return_complaint ad_script_abort ad_script_abort (public) xo::Context instproc process_query_parameter->ad_script_abort

Testcases:
api__context, xotcl-core
Source code:
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}"
XQL Not present:
Generic, PostgreSQL, Oracle
[ hide source ] | [ make this the default ]
Show another procedure: