%3 ::xotcl::Object ::xotcl::Object ::xo::Context ::xo::Context exists_query_parameter export_vars get_parameters original_url_and_query process_query_parameter ::xo::Context->::xotcl::Object ::xowiki::Includelet ::xowiki::Includelet → html_encode ::xowiki::Includelet->::xo::Context ::xo::ConnectionContext ::xo::ConnectionContext → require eval_as_user form_parameter get_all_form_parameter get_parameter permission query_parameter returnredirect set_parameter ::xo::ConnectionContext->::xo::Context ::xowiki::includelet::categories-recent ::xowiki::includelet::categories-recent ::xowiki::includelet::categories-recent->::xowiki::Includelet ::xowiki::includelet::presence ::xowiki::includelet::presence ::xowiki::includelet::presence->::xowiki::Includelet ::xowiki::includelet::recent ::xowiki::includelet::recent ::xowiki::includelet::recent->::xowiki::Includelet ::xowiki::includelet::unresolved-references ::xowiki::includelet::unresolved-references ::xowiki::includelet::unresolved-references->::xowiki::Includelet ::xowiki::includelet::form-stats ::xowiki::includelet::form-stats ::xowiki::includelet::form-stats->::xowiki::Includelet ::xowiki::includelet::link-with-local-return-url ::xowiki::includelet::link-with-local-return-url ::xowiki::includelet::link-with-local-return-url->::xowiki::Includelet ::xowiki::includelet::personal-notification-messages ::xowiki::includelet::personal-notification-messages → get_messages_response → message_add → message_dismiss → modal_message_dialog → modal_message_dialog_register_submit ::xowiki::includelet::personal-notification-messages->::xowiki::Includelet ::xowiki::includelet::wf-todo ::xowiki::includelet::wf-todo ::xowiki::includelet::wf-todo->::xowiki::Includelet ::xowiki::includelet::available-includelets ::xowiki::includelet::available-includelets ::xowiki::includelet::available-includelets->::xowiki::Includelet ::xowiki::includelet::folders ::xowiki::includelet::folders ::xowiki::includelet::folders->::xowiki::Includelet ::xowiki::includelet::toc ::xowiki::includelet::toc build_toc initialize render render_list render_yui_list ::xowiki::includelet::toc->::xowiki::Includelet ::xowiki::includelet::PageReorderSupport ::xowiki::includelet::PageReorderSupport ::xowiki::includelet::toc->::xowiki::includelet::PageReorderSupport ::xowiki::includelet::item-button ::xowiki::includelet::item-button ::xowiki::includelet::item-button->::xowiki::Includelet ::xowiki::includelet::set-parameter ::xowiki::includelet::set-parameter ::xowiki::includelet::set-parameter->::xowiki::Includelet ::xowiki::includelet::my-refers ::xowiki::includelet::my-refers ::xowiki::includelet::my-refers->::xowiki::Includelet ::xowiki::includelet::last-visited ::xowiki::includelet::last-visited ::xowiki::includelet::last-visited->::xowiki::Includelet ::xowiki::includelet::references-graph ::xowiki::includelet::references-graph ::xowiki::includelet::references-graph->::xowiki::Includelet ::xowiki::includelet::current-irc-log ::xowiki::includelet::current-irc-log ::xowiki::includelet::current-irc-log->::xowiki::Includelet ::xowiki::includelet::LTI-LaunchButton ::xowiki::includelet::LTI-LaunchButton ::xowiki::includelet::LTI-LaunchButton->::xowiki::Includelet ::xowiki::includelet::flowplayer ::xowiki::includelet::flowplayer ::xowiki::includelet::flowplayer->::xowiki::Includelet ::xowiki::includelet::graph ::xowiki::includelet::graph ::xowiki::includelet::graph->::xowiki::Includelet ::xowiki::includelet::get ::xowiki::includelet::get ::xowiki::includelet::get->::xowiki::Includelet ::xowiki::includelet::most-popular ::xowiki::includelet::most-popular ::xowiki::includelet::most-popular->::xowiki::Includelet ::xowiki::includelet::my-categories ::xowiki::includelet::my-categories ::xowiki::includelet::my-categories->::xowiki::Includelet ::xowiki::includelet::creation-date ::xowiki::includelet::creation-date ::xowiki::includelet::creation-date->::xowiki::Includelet ::xowiki::includelet::html-file ::xowiki::includelet::html-file ::xowiki::includelet::html-file->::xowiki::Includelet ::xowiki::includelet::random-form-page ::xowiki::includelet::random-form-page ::xowiki::includelet::random-form-page->::xowiki::Includelet ::xowiki::includelet::exam-top-includelet ::xowiki::includelet::exam-top-includelet ::xowiki::includelet::exam-top-includelet->::xowiki::Includelet ::xowiki::includelet::s5 ::xowiki::includelet::s5 ::xowiki::includelet::s5->::xowiki::Includelet ::xowiki::includelet::iframe ::xowiki::includelet::iframe ::xowiki::includelet::iframe->::xowiki::Includelet ::xowiki::includelet::digg ::xowiki::includelet::digg ::xowiki::includelet::digg->::xowiki::Includelet ::xowiki::includelet::community-link ::xowiki::includelet::community-link ::xowiki::includelet::community-link->::xowiki::Includelet ::xowiki::includelet::available-formfields ::xowiki::includelet::available-formfields ::xowiki::includelet::available-formfields->::xowiki::Includelet ::xowiki::includelet::chat_room ::xowiki::includelet::chat_room ::xowiki::includelet::chat_room->::xowiki::Includelet ::xowiki::includelet::form-menu ::xowiki::includelet::form-menu ::xowiki::includelet::form-menu->::xowiki::Includelet ::xowiki::includelet::unread-items ::xowiki::includelet::unread-items ::xowiki::includelet::unread-items->::xowiki::Includelet ::xowiki::includelet::categories ::xowiki::includelet::categories ::xowiki::includelet::categories->::xowiki::Includelet ::xowiki::includelet::rss-button ::xowiki::includelet::rss-button ::xowiki::includelet::rss-button->::xowiki::Includelet ::xowiki::includelet::vspace ::xowiki::includelet::vspace ::xowiki::includelet::vspace->::xowiki::Includelet ::xowiki::includelet::yui-carousel ::xowiki::includelet::yui-carousel ::xowiki::includelet::yui-carousel->::xowiki::Includelet ::xowiki::includelet::my-references ::xowiki::includelet::my-references ::xowiki::includelet::my-references->::xowiki::Includelet ::xowiki::includelet::my-yahoo-publisher ::xowiki::includelet::my-yahoo-publisher ::xowiki::includelet::my-yahoo-publisher->::xowiki::Includelet ::xowiki::includelet::timeline ::xowiki::includelet::timeline ::xowiki::includelet::timeline->::xowiki::Includelet ::xowiki::includelet::kibana ::xowiki::includelet::kibana ::xowiki::includelet::kibana->::xowiki::Includelet ::xowiki::includelet::most-frequent-visitors ::xowiki::includelet::most-frequent-visitors ::xowiki::includelet::most-frequent-visitors->::xowiki::Includelet ::xowiki::includelet::form-usages ::xowiki::includelet::form-usages ::xowiki::includelet::form-usages->::xowiki::Includelet ::xowiki::includelet::chat ::xowiki::includelet::chat ::xowiki::includelet::chat->::xowiki::Includelet ::xowiki::includelet::book ::xowiki::includelet::book ::xowiki::includelet::book->::xowiki::Includelet ::xowiki::includelet::book->::xowiki::includelet::PageReorderSupport ::xowiki::includelet::child-resources ::xowiki::includelet::child-resources render ::xowiki::includelet::child-resources->::xowiki::Includelet ::xowiki::includelet::delicious ::xowiki::includelet::delicious ::xowiki::includelet::delicious->::xowiki::Includelet ::xowiki::includelet::selection ::xowiki::includelet::selection ::xowiki::includelet::selection->::xowiki::Includelet ::xowiki::includelet::selection->::xowiki::includelet::PageReorderSupport instmixin ::xowiki::includelet::countdown-timer ::xowiki::includelet::countdown-timer ::xowiki::includelet::countdown-timer->::xowiki::Includelet ::xowiki::includelet::my-tags ::xowiki::includelet::my-tags ::xowiki::includelet::my-tags->::xowiki::Includelet ::xowiki::includelet::tags ::xowiki::includelet::tags ::xowiki::includelet::tags->::xowiki::Includelet ::xowiki::includelet::bookmarklet-button ::xowiki::includelet::bookmarklet-button ::xowiki::includelet::bookmarklet-button->::xowiki::Includelet ::xowiki::includelet::gravatar ::xowiki::includelet::gravatar ::xowiki::includelet::gravatar->::xowiki::Includelet ::xowiki::includelet::rss-client ::xowiki::includelet::rss-client ::xowiki::includelet::rss-client->::xowiki::Includelet ::xowiki::includelet::my-general-comments ::xowiki::includelet::my-general-comments ::xowiki::includelet::my-general-comments->::xowiki::Includelet

Class ::xo::Context

::xo::Context[i] create ... \
           [ -actual_query (default " ") ] \
           [ -invoke_object invoke_object ] \
           [ -locale locale ] \
           [ -package_id (default "0") ] \
           [ -parameter_declaration (default "") ]

Defined in

Class Relations

  • class: ::xotcl::Class[i]
  • superclass: ::xotcl::Object[i]
  • subclass: ::xowiki::Includelet[i], ::xo::ConnectionContext[i]
::xotcl::Class create ::xo::Context \
     -superclass ::xotcl::Object

Methods (to be applied on instances)

  • exists_query_parameter (scripted)

     <instance of xo::Context[i]> 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[i]> 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[i]> get_parameters

    Convenience 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 2
  • invoke_object (setter)

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

    Testcases:
    create_folder_with_page, xowf, create_workflow_with_instance, create_form_with_form_instance
  • original_url_and_query (scripted)

     <instance of xo::Context[i]> 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[i]> package_id

    Testcases:
    xotcl_core_tutorial_2, xotcl-core, xowiki_test_cases, link_tests
  • process_query_parameter (scripted)

     <instance of xo::Context[i]> 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}"

Variables

::xo::Context set __default_metaclass ::xotcl::Class
::xo::Context set __default_superclass ::xotcl::Object