Index: openacs-4/packages/xotcl-core/tcl/06-package-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/xotcl-core/tcl/06-package-procs.tcl,v diff -u -r1.14 -r1.15 --- openacs-4/packages/xotcl-core/tcl/06-package-procs.tcl 21 Nov 2008 10:55:13 -0000 1.14 +++ openacs-4/packages/xotcl-core/tcl/06-package-procs.tcl 23 Nov 2008 18:08:45 -0000 1.15 @@ -59,6 +59,7 @@ {-actual_query " "} {-original_url_and_query} {-init_url true} + {-keep_cc false} {-form_parameter} } { Create the connection context ::xo::cc and a package object @@ -71,27 +72,32 @@ "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 + 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. } { #my msg "--i [self args], URL=$url, init_url=$init_url" if {$url eq "" && $init_url} { - #set url [ns_conn url] - #my log "--CONN ns_conn url" set url [root_of_host [ad_host]][ns_conn url] + #my log "--CONN ns_conn url -> $url" } - #my log "--cc actual_query = <$actual_query>" - # require connection context - ConnectionContext require \ - -package_id $package_id -user_id $user_id \ - -parameter $parameter -url $url -actual_query $actual_query + # get package_id from url in case it is not known + 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 } - set package_id [::xo::cc package_id] if {[info exists form_parameter]} { ::xo::cc array set form_parameter $form_parameter } @@ -114,6 +120,7 @@ } ::xo::cc export_vars -level 2 + return $package_id } PackageMgr ad_instproc require {{-url ""} package_id} { Index: openacs-4/packages/xotcl-core/tcl/context-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/xotcl-core/tcl/context-procs.tcl,v diff -u -r1.44 -r1.45 --- openacs-4/packages/xotcl-core/tcl/context-procs.tcl 9 Oct 2008 10:57:15 -0000 1.44 +++ openacs-4/packages/xotcl-core/tcl/context-procs.tcl 23 Nov 2008 18:08:45 -0000 1.45 @@ -176,28 +176,39 @@ url } - # TODO edit revision loop + ConnectionContext proc require_package_id_from_url {{-package_id 0} url} { + # get package_id from url in case it is not known + if {$package_id == 0} { + array set "" [site_node::get_from_url -url $url] + set package_id $(package_id) + #my msg "--i setting pkg to $package_id" + } + return $package_id + } ConnectionContext proc require { -url {-package_id 0} {-parameter ""} {-user_id -1} {-actual_query " "} + {-keep_cc false} } { + set exists_cc [my isobject ::xo::cc] + + # if we have a connection context and we want to keep it, do + # nothing and return. + if {$exists_cc && $keep_cc} { + return + } + if {![info exists url]} { #my log "--CONN ns_conn url" set url [ns_conn url] } + set package_id [my require_package_id_from_url -package_id $package_id $url] #my log "--i [self args] URL='$url', pkg=$package_id" - # create connection context if necessary - if {$package_id == 0} { - array set "" [site_node::get_from_url -url $url] - set package_id $(package_id) - #my msg "--i setting pkg to $package_id" - } - # get locale; TODO at some time, we should get rid of the ad_conn init problem if {[ns_conn isconnected]} { # This can be called, before ad_conn is initialized. @@ -209,7 +220,7 @@ } else { set locale [lang::system::locale -package_id $package_id] } - if {![my isobject ::xo::cc]} { + if {!$exists_cc} { my create ::xo::cc \ -package_id $package_id \ [list -parameter_declaration $parameter] \