xotcl.wu-wien.ac.at
Begin main content
Methods: Source: Variables:
[All Methods | Documented Methods | Hide Methods] [Display Source | Hide Source] [Show Variables | Hide Variables]

::xotcl::Class[i] ::xo::Context

Class Hierarchy of ::xo::Context

  • ::xotcl::Object[i]
    Meta-class:
    ::xotcl::Class[i]
    Methods for instances:
    __api_make_doc, __api_make_forward_doc, __timediff, abstract, ad_doc, ad_forward, ad_proc, appendC, arrayC, asHTML, autonameC, check, classC, cleanupC, configureC, containsC, copyC, db_0or1rowC, db_1rowC, debug, defaultmethodC, destroyC, destroy_on_cleanup, ds, evalC, existsC, extractConfigureArg, filterC, filterguardC, filtersearch, forward, hasclass, incrC, infoC, init, instvarC, invarC, isclass, ismetaclass, ismixin, isobject, istype, lappendC, log, method, mixinC, mixinguardC, moveC, msg, noinitC, objectparameter, parametercmdC, proc, procsearch, qn, requireNamespaceC, residualargsC, self, serialize, setC, set_instance_vars_defaults, show-object, substC, traceC, unknown, unsetC, uplevelC, upvarC, volatileC, vwait
    Methods to be applied on the class (in addition to the methods provided by the meta-class):
    getExitHandler, setExitHandler, unsetExitHandler
    • ::xo::Context[i]
      Meta-class:
      ::xotcl::Class[i]
      Parameter for instances:
      actual_query (default " "), locale, package_id (default "0"), parameter_declaration (default "")
      Methods for instances:
      exists_query_parameter, export_vars, get_all_query_parameter, get_parameters, initialize, original_url_and_query, process_query_parameter, query_parameter
      Methods to be applied on the class:
      Methods provided by the meta-class
This class provides a context for evaluation, somewhat similar to an activation record in programming languages. It combines the parameter declaration (e.g. of a page, an includelet) with the actual parameters (specified in an includelet) and the provided query values (from the url). The parameter decaration are actually XOTcl's non positional arguments.
Defined in packages/xotcl-core/tcl/context-procs.tcl

Class Relations

  • superclass: ::xotcl::Object[i]
  • subclass: ::xo::ConnectionContext[i], ::xowiki::Includelet[i]
::xotcl::Class create ::xo::Context \
     -superclass ::xotcl::Object \
     -parameter {{actual_query " "} locale {package_id 0} {parameter_declaration ""}}

Methods

  • instproc exists_query_parameter

    ::2078273 instproc exists_query_parameter name {
        #my log "--qp my exists $name => [my exists queryparm($name)]"
        my exists queryparm($name)
      }
    
  • instproc export_vars (public)

    <instance of ::xo::Context[i]> export_vars [ -level level ]
    Export the query variables

    Switches:
    -level (defaults to "1") (optional)
    target level
    ::2078273 instproc export_vars {{-level 1}} {
        my instvar queryparm package_id
    
        foreach p [my array names queryparm] {
          regsub -all : $p _ varName
          uplevel $level [list set $varName [my set queryparm($p)]]
        }
        uplevel $level [list set package_id $package_id]
        #::xo::show_stack
      }
    
  • instproc get_all_query_parameter

    ::2078273 instproc get_all_query_parameter {} {
        return [my array get queryparm]
      }
    
  • instproc get_parameters (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) wit the values from the url (second priority) and the default values from the signature

    ::2078273 instproc get_parameters {} {
        set source [expr {[my exists __caller_parameters] ? 
                          [self] : [my info parent]}]
        $source instvar __caller_parameters
        
        if {![my exists __including_page]} {
          # a includelet is called from the toplevel. the actual_query might
          # be cached, so we reset it here.
          my actual_query [::xo::cc actual_query]
        }
    
        if {[info exists __caller_parameters]} {
          my process_query_parameter -all_from_query false -caller_parameters $__caller_parameters
        } else {
          my process_query_parameter -all_from_query false
        }
        my export_vars -level 2 
      }
    
  • instproc initialize

    ::2078273 instproc initialize {{-parameter ""}} {
        my set parameter_declaration $parameter
      }
    
  • instproc original_url_and_query

    ::2078273 instproc original_url_and_query args {
        if {[llength $args] == 1} {
          my set original_url_and_query [lindex $args 0]
        } elseif {[my exists original_url_and_query]} {
          return [my set original_url_and_query]
        } else {
          return [my url]?[my actual_query]
        }
      }
    
  • instproc process_query_parameter

    ::2078273 instproc process_query_parameter {{-all_from_query:boolean true} {-all_from_caller:boolean true} -caller_parameters} {
        my instvar queryparm actual_query 
        my proc __parse [my parameter_declaration]  {
          foreach v [info vars] { uplevel [list set queryparm($v) [set $v]]}
        }
        
        foreach v [my parameter_declaration] {
          set ([lindex [split [lindex $v 0] :] 0]) 1
        }
        if {$actual_query eq " "} {
          if {[ns_conn isconnected]} {
    	set actual_query [ns_conn query]
          }
          #my log "--CONN ns_conn query = <$actual_query>"
        }
    
        set decodeCmd ns_urldecode
        if {$::xo::naviserver} {lappend decodeCmd --}
    
        # get the query parameters (from the url)
        #my log "--P processing actual query $actual_query"
        foreach querypart [split $actual_query &] {
          set name_value_pair [split $querypart =]
          set att_name [{*}$decodeCmd [lindex $name_value_pair 0]]
          if {$att_name eq ""} continue
          if {[llength $name_value_pair] == 1} { 
            set att_value 1 
          }  else {
            set att_value [{*}$decodeCmd [lindex $name_value_pair 1]]
          }
          if {[info exists (-$att_name)]} {
            lappend passed_args(-$att_name) $att_value
          } elseif {$all_from_query} {
            set queryparm($att_name) $att_value
          }
        }
    
        # get the query parameters (from the form if necessary)
        if {[my istype ::xo::ConnectionContext]} {
          foreach param [array names ""] {
    	#my log "--cc check $param [info exists passed_args($param)]"
    	set name [string range $param 1 end]
    	if {![info exists passed_args($param)] &&
    	    [my exists_form_parameter $name]} {
    	  #my log "--cc adding passed_args(-$name) [my form_parameter $name]"
    	  set passed_args($param) [my form_parameter $name]
    	}
          }
        }
        
        # get the caller parameters (e.g. from the includelet call)
        if {[info exists caller_parameters]} {
          #my log "--cc caller_parameters=$caller_parameters"
          array set caller_param $caller_parameters
        
          foreach param [array names caller_param] {
            if {[info exists ($param)]} { 
              set passed_args($param) $caller_param($param) 
            } elseif {$all_from_caller} {
              set queryparm([string range $param 1 end]) $caller_param($param) 
            }
          }
        }
    
        set parse_args [list]
        foreach param [array names passed_args] {
          lappend parse_args $param $passed_args($param)
        }
        
        #my log "--cc calling parser eval [self] __parse $parse_args"
        eval [self] __parse $parse_args
        #my msg "--cc qp [array get queryparm] // $actual_query"
      }
    
  • instproc query_parameter

    ::2078273 instproc query_parameter {name {default {}}} {
        my instvar queryparm
        return [expr {[info exists queryparm($name)] ? $queryparm($name) : $default}]
      }
    

Methods: Source: Variables:
[All Methods | Documented Methods | Hide Methods] [Display Source | Hide Source] [Show Variables | Hide Variables]