xowiki::Package instproc invoke (public)
<instance of xowiki::Package> invoke [ -method method ] \ [ -error_template error_template ] [ -batch_mode on|off ]
Defined in /var/www/openacs/packages/xowiki/tcl/package-procs.tcl
Resolve the requested page or package and invoke the requested method.
- Switches:
- -method (optional)
- Requested method name.
- -error_template (optional, defaults to
"error-template")- Template for reporting invocation errors.
- -batch_mode (optional, boolean, defaults to
"0")- Whether invocation is in batch mode.
- Testcases:
- create_folder_with_page, create_workflow_with_instance, create_form_with_form_instance
Source code: # # Do we have a valid method? # if {![regexp {^[.a-zA-Z0-9_-]+$} $method]} { return [:error_msg "No valid method provided!"] } # # Call the method on the resolved page. This call might trigger an # ad_script_abort, so use ad_try to catch these properly. # ad_try { set page_or_package [:resolve_page -lang [:default_language] ${:object} method] } on error {errorMsg} { # # Report true errors in the error log and return the template. # ad_log error $errorMsg return [:error_msg -template_file $error_template [ns_quotehtml $errorMsg]] } # # Set the invoke object, such it might be used later # ::xo::cc invoke_object $page_or_package #:log "--r resolve_page '${:object}' => $page_or_package" if {$page_or_package ne ""} { # TODO: remove me when settled if {[$page_or_package istype ::xowiki::FormPage] && [$page_or_package info vars storage_type] eq ""} {ad_log notice "$page_or_package has no storage_type"} # # Check, of the target is a symbolic link # if {[$page_or_package istype ::xowiki::FormPage] && [$page_or_package is_link_page] } { # # If the target is a symbolic link, we may want to call the # method on the target. The default behavior is defined in the # array delegate_link_to_target, but if can be overruled with # the boolean query parameter "deref". # set deref [[self class] exists delegate_link_to_target($method)] if {[:exists_query_parameter deref]} { set deref [:query_parameter deref:boolean] } #:log "LINK <$method> default deref $deref" if {$deref} { set target [$page_or_package get_target_from_link_page] #:log "delegate $method from $page_or_package [$page_or_package name] to $target [$target name]" if {$target ne ""} { $target set __link_source $page_or_package set page_or_package $target } } } #:log "call procsearch www-$method on: [$page_or_package info precedence]" if {[$page_or_package procsearch www-$method] eq ""} { return [:error_msg "Method <b>'[ns_quotehtml $method]'</b> is not defined for this object"] } else { #:log "${:object} id=$page_or_package method=$method (${:id} batch_mode $batch_mode)" if {$batch_mode} { ${:id} set __batch_mode 1 } ad_try { set r [:call $page_or_package $method ""] } on error {errorMsg} { if {[string match "*for parameter*" $errorMsg]} { # # The exception might have been due to invalid input parameters # ad_return_complaint 1 [ns_quotehtml $errorMsg] ad_script_abort } else { # # The exception was a real error # ad_log error "error during invocation of method $method errorMsg: $errorMsg, $::errorInfo" return [:error_msg -status_code 500 -template_file $error_template "error during [ns_quotehtml $method]: <pre>[ns_quotehtml $errorMsg]</pre>"] } } finally { if {$batch_mode} { ${:id} unset -nocomplain __batch_mode } } return $r } } else { # # The requested page was not found, provide an error message and # an optional link for creating the page. The creation link # depends on the method "create_new_snippet", which checks # whether the policy in place supports "edit-new" permissions # for the current user. # set path [::xowiki::Includelet html_encode ${:object}] set edit_snippet [:create_new_snippet $path] return [:error_msg -status_code 404 -template_file $error_template "Page <b>'[ns_quotehtml $path]'</b> is not available. $edit_snippet"] }XQL Not present: Generic, PostgreSQL, Oracle
![[i]](/resources/acs-subsite/ZoomIn16.gif)