Index: openacs-4/packages/acs-tcl/tcl/db-query-dispatcher-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-tcl/tcl/Attic/db-query-dispatcher-procs.tcl,v diff -u -N -r1.6 -r1.7 --- openacs-4/packages/acs-tcl/tcl/db-query-dispatcher-procs.tcl 16 Apr 2001 21:59:47 -0000 1.6 +++ openacs-4/packages/acs-tcl/tcl/db-query-dispatcher-procs.tcl 17 Apr 2001 22:59:51 -0000 1.7 @@ -154,17 +154,10 @@ # We do a check to see if we already have a fullname. # Since the DB procs are a bit incestuous, this might get # called more than once. DAMMIT! (ben) - if {[regexp {^acs\.} $local_name all]} { + if {![db_qd_relative_path_p $local_name]} { return $local_name } - # Test stuff (ben) - for {set i 0} {$i < 5} {incr i} { - if {[catch {ns_log Notice "QD = LEVEL $i = [info level [expr "0 - $i"]]"} errmsg]} { - break - } - } - # Get the proc name being executed. set proc_name [info level [expr "-1 - $added_stack_num"]] @@ -200,9 +193,11 @@ ns_log Notice "QD = package key is $package_key and rest is $rest" if {$real_url_p} { - set full_name "acs.${package_key}.www${rest}.${local_name}" + set full_name [db_qd_make_absolute_path "${package_key}.www${rest}." $local_name] + # set full_name "acs.${package_key}.www${rest}.${local_name}" } else { - set full_name "acs.${package_key}${rest}.${local_name}" + set full_name [db_qd_make_absolute_path "${package_key}${rest}." $local_name] + # set full_name "acs.${package_key}${rest}.${local_name}" } } else { # Let's find out where this Tcl proc is defined!! @@ -218,7 +213,7 @@ # return a bogus proc name if {![nsv_exists api_proc_doc $proc_name]} { ns_log Notice "QD: there is no documented proc with name $proc_name -- we used default SQL" - return "acs.NULL" + return [db_qd_null_path] } array set doc_elements [nsv_get api_proc_doc $proc_name] @@ -239,9 +234,11 @@ ns_log Notice "TEMP - QD: proc_name is $proc_name" ns_log Notice "TEMP - QD: local_name is $local_name" - set full_name "acs.$rest.${proc_name}.${local_name}" + # set full_name "acs.$rest.${proc_name}.${local_name}" + set full_name [db_qd_make_absolute_path "${rest}.${proc_name}." $local_name] } + ns_log Notice "QD= generated fullname of $full_name" return $full_name } @@ -332,8 +329,8 @@ ns_log Notice "QD = loaded one query - [db_fullquery_get_name $one_query]" # Relative Path for the Query - if {[string range [db_fullquery_get_name $one_query] 0 0] == "."} { - set new_name "acs.${queryname_root}[db_fullquery_get_name $one_query]" + if {[db_qd_relative_path_p [db_fullquery_get_name $one_query]]} { + set new_name [db_qd_make_absolute_path $queryname_root [db_fullquery_get_name $one_query]] set new_fullquery [db_fullquery_create \ $new_name \ @@ -423,16 +420,19 @@ # remove the prepended "/packages/" string regsub {^\/?packages\/} $relative_path {} relative_path - # remove the last component, the file name, since we're just looking for the root path - regsub {/[^/]*$} $relative_path {} relative_path + # remove the last chunk of the file name, since we're just looking for the root path + # NOTE: THIS MAY NEED BETTER ABSTRACTION, since this assumes a naming scheme + # of -rdbms.XXX (ben) + regsub {\-[^/-]*$} $relative_path {} relative_path # Change all . to : regsub -all {\.} $relative_path {:} relative_path # Change all / to . (hah, no reference to News for Nerds) regsub -all {/} $relative_path {.} relative_path - return $relative_path + # We append a "." at the end, since we want easy concatenation + return "${relative_path}." } ## @@ -568,4 +568,36 @@ ns_log Notice "QD/PARSER = RDBMS parser - $type - $version" return [db_rdbms_create $type $version] +} + + +## +## RELATIVE AND ABSOLUTE QUERY PATHS +## + +# The token that indicates the root of all queries +proc db_qd_root_path {} { + return "dbqd." +} + +proc db_qd_null_path {} { + return "[db_qd_root_path].NULL" +} + +# Check if the path is relative +proc db_qd_relative_path_p {path} { + set root_path [db_qd_root_path] + set root_path_length [string length $root_path] + + # Check if the path starts with the root + if {[string range $path 0 [expr "$root_path_length - 1"]] == $root_path} { + return 0 + } else { + return 1 + } +} + +# Make a path absolute +proc db_qd_make_absolute_path {relative_root suffix} { + return "[db_qd_root_path]${relative_root}$suffix" } \ No newline at end of file