xo::ConnectionContext proc require
xo::ConnectionContext require
- Testcases:
- test_xo_cc, xotcl-core
Source code: # # This is a private method used for low-level connection context # creation. This function has to be called either with a valid # "-url" when being used outside connection threads. # set exists_cc [nsf::is object ::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 ::ds_show_p] && [ds_database_enabled_p]} { ::xo::dc profile on } if {![info exists url]} { #:log "--CONN ns_conn url" if {[ns_conn isconnected]} { set url [ad_conn url] } else { set url "" ad_log error "fallback to empty url" } } set package_id [:require_package_id_from_url -package_id $package_id $url] #:log "--i [self args] URL='$url', pkg=$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. # Since it is not possible to pass the user_id and ad_conn barfs # when it tries to detect it, we try to get it and reset it later ad_try { set locale [lang::conn::locale -package_id $package_id] } on error {errorMsg} { ns_log warning "fall back to locale en_US" set locale en_US } } else { set locale [lang::system::locale -package_id $package_id] } if {!$exists_cc} { try { :create ::xo::cc -package_id $package_id -parameter_declaration $parameter -user_id $user_id -actual_query $actual_query -locale $locale -url $url } on error {errorMsg} { if {[nsf::is object ::xo::cc]} { ::xo::cc destroy } return -code error -errorcode $::errorCode -errorinfo $::errorInfo $errorMsg } ::xo::cc destroy_on_cleanup # if {[ns_conn isconnected]} { # ns_log notice "XXX ::xo::cc created [ns_conn id] [ns_conn request]" # ::xo::cc set ID [ns_conn id] # } else { # ns_log notice "XXX ::xo::cc created without connection" # ::xo::cc set ID UNKNOWN # } # ::xo::cc proc destroy {args} { # set ID [expr {[info exists :ID] ? ${:ID} : {-}}] # ns_log notice "::xo::cc destroyed ID $ID" # next # } #::xo::show_stack #:msg "--cc ::xo::cc created $url [::xo::cc serialize]" } else { #:msg "--cc ::xo::cc reused $url -package_id $package_id" ::xo::cc configure -url $url -actual_query $actual_query -locale $locale -parameter_declaration $parameter ::xo::cc package_id $package_id ::xo::cc set_user_id $user_id ::xo::cc process_query_parameter } # simple mobile detection ::xo::cc mobile 0 if {[ns_conn isconnected]} { set user_agent [string tolower [ns_set iget [ns_conn headers] User-Agent]] ::xo::cc mobile [regexp (android|webos|iphone|ipad) $user_agent] } if {![info exists ::ad_conn(charset)]} { set ::ad_conn(charset) [lang::util::charset_for_locale $locale] set ::ad_conn(language) [::xo::cc lang] set ::ad_conn(file) "" }XQL Not present: Generic, PostgreSQL, Oracle