xo::PackageMgr instproc initialize (public)
<instance of xo::PackageMgr> initialize [ -ad_doc ad_doc ] \ [ -parameter parameter ] [ -package_id package_id ] [ -url url ] \ [ -user_id user_id ] [ -actual_query actual_query ] \ [ -original_url_and_query original_url_and_query ] \ [ -init_url init_url ] [ -keep_cc keep_cc ] \ [ -form_parameter form_parameter ] [ -export_vars export_vars ]
Defined in /var/www/openacs.org/packages/xotcl-core/tcl/06-package-procs.tcl
Create the connection context ::xo::cc and a package object if these are none defined yet. The connection context ::xo::cc and the package object will be destroyed on cleanup, when the global variables are reclaimed. As a side effect this method sets in the calling context the query parameters and package_id as variables, using the "defaults" for default values. init_url false requires the package_id to be specified and a call to Package instproc set_url to complete initialization. keep_cc true means that the original connection context is preserved (i.e. not altered) in case it exists already.
- Switches:
- -ad_doc (optional)
- -parameter (optional)
- -package_id (optional, defaults to
"0"
)- -url (optional)
- -user_id (optional, defaults to
"-1"
)- -actual_query (optional, defaults to
" "
)- -original_url_and_query (optional)
- -init_url (optional, defaults to
"true"
)- -keep_cc (optional, defaults to
"false"
)- -form_parameter (optional)
- -export_vars (optional, defaults to
"true"
)- Testcases:
- package_normalize_path, includelet_toc, includelet_childresources, xowiki_test_cases, link_tests, slot_interactions, path_resolve, create_form_with_form_instance
Source code: #:msg "--i [self args], URL=$url, init_url=$init_url" if {[info exists ad_doc] && [api_page_documentation_mode_p]} { ad_parse_documentation_string $ad_doc doc_elements set doc_elements(query) $parameter error [array get doc_elements] "ad_page_contract documentation" } if {$url eq "" && $init_url} { if {[ns_conn isconnected]} { set url [acs::root_of_host [ad_host]][ns_conn url] } else { # # In case, we are not connected and no URL path is provided, # we do a best effort job to set the "url" variable to a path # belonging to the right package. The is no way to provide # here a better approximation. Note that if e.g. a batch job # needs a more precise (object_specific) url, this has to be # generated on the caller side with [$object_id pretty_link] # or similar means. # set url [lindex [site_node::get_url_from_object_id -object_id $package_id] 0] ns_log warning "PackageMgr initialize sets best-effort URL <$url>" } #:log "--CONN ns_conn url -> $url" } # # Get package_id from url in case it is not known. When the # package_id is already known, this is a noop. # set package_id [ConnectionContext require_package_id_from_url -package_id $package_id $url] # # Require connection context if needed # ConnectionContext require -keep_cc $keep_cc -package_id $package_id -user_id $user_id -parameter $parameter -url $url -actual_query $actual_query if {[info exists original_url_and_query]} { ::xo::cc original_url_and_query $original_url_and_query } if {[info exists form_parameter]} { ::xo::cc array set form_parameter $form_parameter } # # Create package object instance if necessary. # if {$keep_cc} { :require $package_id } else { :require -url $url $package_id } # # In case the login expired, we can force an early login to # prevent later login redirects, which can cause problems # from within catch operations. The package can decide, if # it want to force a refresh of the login, even if some pages # might not require the real user_id. # #:msg "force [::$package_id force_refresh_login] && # [::xo::cc set untrusted_user_id] != [::xo::cc user_id]" if {[::$package_id force_refresh_login] && [::xo::cc set untrusted_user_id] != [::xo::cc user_id]} { auth::require_login } if {$export_vars} { ::xo::cc export_vars -level 2 } return $package_idXQL Not present: Generic, PostgreSQL, Oracle