Index: openacs-4/packages/xotcl-core/tcl/50-protocol-handler-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/xotcl-core/tcl/50-protocol-handler-procs.tcl,v diff -u -r1.10 -r1.11 --- openacs-4/packages/xotcl-core/tcl/50-protocol-handler-procs.tcl 7 Aug 2017 23:48:30 -0000 1.10 +++ openacs-4/packages/xotcl-core/tcl/50-protocol-handler-procs.tcl 21 Oct 2017 13:07:27 -0000 1.11 @@ -7,12 +7,12 @@ ProtocolHandler ad_instproc unknown {method args} { Return connection information similar to ad_conn } { - my log "--[self class] unknown called with '$method' <$args>" + :log "--[self class] unknown called with '$method' <$args>" switch -- [llength $args] { - 0 {if {[my exists $method]} {return [my set method]} + 0 {if {[info exists :$method]} {return ${:method}} return [ad_conn $method] } - 1 {my set method $args} + 1 {set :method $args} default {my log "--[self class] ignoring <$method> <$args>"} } } @@ -23,7 +23,7 @@ set ah [ns_set get [ns_conn headers] Authorization] if {$ah ne ""} { # should be something like "Basic 29234k3j49a" - my debug "auth_check authentication info $ah" + :debug "auth_check authentication info $ah" # get the second bit, the base64 encoded bit set up [lindex [split $ah " "] 1] # after decoding, it should be user:password; get the username @@ -32,65 +32,63 @@ -username $user \ -authority_id [::auth::get_register_authority] \ -password $password] - my debug "auth $user $password returned [array get auth]" + :debug "auth $user $password returned [array get auth]" if {$auth(auth_status) ne "ok"} { array set auth [auth::authenticate \ -email $user \ -password $password] if {$auth(auth_status) ne "ok"} { - my debug "auth status $auth(auth_status)" + :debug "auth status $auth(auth_status)" ns_returnunauthorized - my set user_id 0 + set :user_id 0 return 0 } } - my debug "auth_check user_id='$auth(user_id)'" + :debug "auth_check user_id='$auth(user_id)'" ad_conn -set user_id $auth(user_id) } else { # no authenticate header, anonymous visitor ad_conn -set user_id 0 ad_conn -set untrusted_user_id 0 } - my set user_id [ad_conn user_id] + set :user_id [ad_conn user_id] } ProtocolHandler ad_instproc initialize {} { Setup connection object and authenticate user } { - my instvar uri method url urlv destination ad_conn -reset # Make sure, there is no ::ad_conn(request); otherwise the # developer support will add all its output to a single var, which # can lead easily to running out of resources in busy sites. When # unset, the developer support will create its own id. catch {unset ::ad_conn(request)} - set uri [ns_urldecode [ns_conn url]] - if {[string length $uri] < [string length $url]} {append uri /} - set url_regexp "^[my url]" - regsub $url_regexp $uri {} uri - if {![regexp {^[./]} $uri]} {set uri /$uri} - #my log "--conn_setup: uri '$uri' my url='[my url]' con='[ns_conn url]'" - my set_user_id + set :uri [ns_urldecode [ns_conn url]] + if {[string length ${:uri}] < [string length ${:url}]} {append :uri /} + set url_regexp "^${:url}" + regsub $url_regexp ${:uri} {} :uri + if {![regexp {^[./]} ${:uri}]} {set :uri /${:uri}} + #my log "--conn_setup: uri '${:uri}' my url='${:url}' con='[ns_conn url]'" + :set_user_id - set method [string toupper [ns_conn method]] - #my log "--conn_setup: uri '$uri' method $method" - set urlv [split [string trimright $uri "/"] "/"] - my set user_agent [ns_set iget [ns_conn headers] user-agent] - set destination [ns_urldecode [ns_set iget [ns_conn headers] Destination]] - if {$destination ne ""} { - regsub {https?://[^/]+/} $destination {/} dest - regsub $url_regexp $dest {} destination - if {![regexp {^[./]} $destination]} {set destination /$destination} + set :method [string toupper [ns_conn method]] + #my log "--conn_setup: uri '${:uri}' method ${:method}" + set :urlv [split [string trimright ${:uri} "/"] "/"] + set :user_agent [ns_set iget [ns_conn headers] user-agent] + set :destination [ns_urldecode [ns_set iget [ns_conn headers] Destination]] + if {${:destination} ne ""} { + regsub {https?://[^/]+/} ${:destination} {/} dest + regsub $url_regexp $dest {} :destination + if {![regexp {^[./]} ${:destination}]} {set :destination /${:destination}} } - #my log "--conn_setup: method $method destination '$destination' uri '$uri'" + #my log "--conn_setup: method ${:method} destination '${:destination}' uri '${:uri}'" } ProtocolHandler ad_instproc preauth { args } { Handle authorization. This method is called via ns_filter. } { #my log "--preauth args=<$args>" - my instvar user_id # Restrict to SSL if required if { [security::RestrictLoginToSSLP] && ![security::secure_conn_p] } { @@ -99,10 +97,10 @@ } # set common data for all kind of requests - my initialize + :initialize # for now, require for every user authentification - if {$user_id == 0} { + if {${:user_id} == 0} { ns_returnunauthorized return filter_return } @@ -123,9 +121,9 @@ filter before the request processor (currently, there are no hooks for that). } { - set filter_url [my url]* - set url [my url]/* - set root [string trimright [my url] /] + set filter_url [:url]* + set url [:url]/* + set root [string trimright [:url] /] # # Methods defined by RFC 2086 (19.6.1 Additional Request Methods): # @@ -194,27 +192,24 @@ Initialize the given package and return the package_id @return package_id } { - my instvar uri package - $package initialize -url $uri - #my log "--[my package] initialize -url $uri" + ${:package} initialize -url ${:uri} + #my log "-- ${:package} initialize -url ${:uri}" return $package_id } ProtocolHandler ad_instproc handle_request { args } { Process the incoming HTTP request. This method could be overloaded by the application and dispatches the HTTP requests. - } { - my instvar uri method user_id - - #my log "--handle_request method=$method uri=$uri\ - # userid=$user_id -ns_conn query '[ns_conn query]'" - if {[my exists package] && $uri ne "/"} { - # We don't call package-initialze for $uri = "/" - my set package_id [my get_package_id] + } { + #my log "--handle_request method=${:method} uri=$uri\ + # userid=${:user_id} -ns_conn query '[ns_conn query]'" + if {[info exists :package] && ${:uri} ne "/"} { + # We don't call package-initialze for ${:uri} = "/" + set :package_id [:get_package_id] } - if {[my procsearch $method] ne ""} { - my $method + if {[:procsearch ${:method}] ne ""} { + my ${:method} } else { ns_return 404 text/plain "not implemented" } @@ -238,7 +233,7 @@ ProtocolHandler instproc tcl_time_to_http_date {datetime} { # RFC2518 requires this e.g. for getlastmodified if {$datetime eq ""} return "" - return [my http_date [clock scan [::xo::db::tcl_date $datetime tz]]] + return [:http_date [clock scan [::xo::db::tcl_date $datetime tz]]] } ProtocolHandler instproc multiStatus {body} { @@ -290,22 +285,22 @@ D:getcontentlength "" \ D:creationdate "" \ D:resourcetype "" - set r [my multiStatus [my multiStatusResonse \ + set r [:multiStatus [:multiStatusResonse \ -href [ns_urldecode [ns_conn url]] \ -propstats [list $davprops $status]]] - my log multiStatusError=$r + :log multiStatusError=$r ns_return 207 text/xml $r } # # Some dummy HTTP methods # ProtocolHandler instproc GET {} { - my log "--GET method" - ns_return 200 text/plain GET-[my set uri] + :log "--GET method" + ns_return 200 text/plain GET-${:uri} } ProtocolHandler instproc PUT {} { - my log "--PUT method [ns_conn content]" + :log "--PUT method [ns_conn content]" ns_return 201 text/plain "received put with content-length [string length [ns_conn content]]" } @@ -320,13 +315,13 @@ # see http://www.webdav.org/specs/rfc4918.html, 9.1.5 lappend davprops \ lp1:resourcetype \ - lp1:creationdate [my tcl_time_to_iso8601 "2013-06-30 01:21:22.648325+02"] \ + lp1:creationdate [:tcl_time_to_iso8601 "2013-06-30 01:21:22.648325+02"] \ D:supportedlock {} \ D:lockdiscovery {} - ns_return 207 text/xml [my multiStatus \ - [my multiStatusResonse \ - -href [my set uri] \ + ns_return 207 text/xml [:multiStatus \ + [:multiStatusResonse \ + -href ${:uri} \ -propstats [list $davprops "HTTP/1.1 200 OK"]]] } @@ -336,7 +331,7 @@ ns_return 200 text/plain {} } ::xo::minimalProctocolHandler proc PROPFIND {args} { - my multiStatusError "HTTP/1.1 403 Forbidden" + :multiStatusError "HTTP/1.1 403 Forbidden" } }