Index: openacs-4/packages/acs-kernel/sql/postgresql/apm-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-kernel/sql/postgresql/apm-create.sql,v diff -u -r1.3 -r1.4 --- openacs-4/packages/acs-kernel/sql/postgresql/apm-create.sql 21 Mar 2001 05:46:40 -0000 1.3 +++ openacs-4/packages/acs-kernel/sql/postgresql/apm-create.sql 30 Mar 2001 05:44:47 -0000 1.4 @@ -241,9 +241,10 @@ constraint apm_package_vers_ver_uri_nn not null constraint apm_package_vers_ver_uri_un unique, summary varchar(3000) default '' not null, - description_format varchar(100) + description_format varchar(100) + constraint apm_package_vers_desc_for_nn not null constraint apm_package_vers_desc_for_ck - check (description_format in ('text/html', 'text/plain')), + check (description_format in ('', 'text/html', 'text/plain')), description text default '' not null, release_date timestamp, vendor varchar(500) default '' not null, @@ -2255,7 +2256,7 @@ apm_pkg_ver__data_model_loaded_p alias for $12; v_version_id apm_package_versions.version_id%TYPE; begin - if apm_pkg_ver__version_id is null then + if apm_pkg_ver__version_id='''' then select acs_object_id_seq.nextval into v_version_id from dual; Index: openacs-4/packages/acs-tcl/tcl/10-database-procs-postgresql.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-tcl/tcl/Attic/10-database-procs-postgresql.tcl,v diff -u -r1.2 -r1.3 --- openacs-4/packages/acs-tcl/tcl/10-database-procs-postgresql.tcl 27 Mar 2001 23:12:27 -0000 1.2 +++ openacs-4/packages/acs-tcl/tcl/10-database-procs-postgresql.tcl 30 Mar 2001 05:44:47 -0000 1.3 @@ -23,14 +23,24 @@ OpenACS requires the caller to perform a select query that returns the value of the function. + We are no longer calling db_string, which screws up the bind variable + stuff otherwise because of calling environments. (ben) + } { ad_arg_parser { bind_output } $args + + # I'm not happy about having to get the fullname here, but right now + # I can't figure out a cleaner way to do it. I will have to + # revisit this ASAP. (ben) + set full_statement_name [db_fullquery_get_fullname $statement_name] + if { [info exists bind_output] } { return -code error "the -bind_output switch is not currently supported" } db_with_handle db { - return [db_string $statement_name $sql] + set selection [db_exec 0or1row $db $full_statement_name $sql] + return [ns_set value $selection 0] } } Index: openacs-4/packages/acs-tcl/tcl/10-database-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-tcl/tcl/Attic/10-database-procs.tcl,v diff -u -r1.4 -r1.5 --- openacs-4/packages/acs-tcl/tcl/10-database-procs.tcl 27 Mar 2001 23:12:27 -0000 1.4 +++ openacs-4/packages/acs-tcl/tcl/10-database-procs.tcl 30 Mar 2001 05:44:47 -0000 1.5 @@ -233,6 +233,9 @@ } } { + # Query Dispatcher (OpenACS - ben) + set full_statement_name [db_fullquery_get_fullname $statement_name] + ad_arg_parser { bind column_array column_set args } $args # Do some syntax checking. @@ -264,7 +267,7 @@ } db_with_handle db { - set selection [db_exec select $db $statement_name $sql] + set selection [db_exec select $db $full_statement_name $sql] set counter 0 while { [db_getrow $db $selection] } { @@ -434,6 +437,9 @@ } { ad_arg_parser { bind column_array column_set } $args + # Query Dispatcher (OpenACS - ben) + set full_statement_name [db_fullquery_get_fullname $statement_name] + if { [info exists column_array] && [info exists column_set] } { return -code error "Can't specify both column_array and column_set" } @@ -450,7 +456,7 @@ } db_with_handle db { - set selection [db_exec 0or1row $db $statement_name $sql] + set selection [db_exec 0or1row $db $full_statement_name $sql] } if { [empty_string_p $selection] } { Index: openacs-4/packages/acs-tcl/tcl/50-xml-utils-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-tcl/tcl/Attic/50-xml-utils-procs.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/acs-tcl/tcl/50-xml-utils-procs.tcl 30 Mar 2001 05:44:47 -0000 1.1 @@ -0,0 +1,28 @@ + +# 50-xml-utils-procs.tcl +# (ben for OpenACS) +# +# This is a set of utilities for dealing with XML in a nice way, +# using ns_xml. Since ns_xml only offers a very basic interface to +# accessing XML documents, we add additional functions. As ns_xml gets +# better, it's perfectly conceivable that these functions will be +# implemented more efficiently by calling ns_xml more directly. +# +# It would be nice if this could be used without the ACS, so we're not +# using ad_proc constructs for this at this point. + +# Find nodes of a parent that have a given name +proc xml_find_child_nodes {parent_node name} { + set children [ns_xml node children $parent_node] + + set list_of_appropriate_children [list] + + foreach child $children { + if {[ns_xml node name $child] == $name} { + lappend list_of_appropriate_children $child + } + } + + return $list_of_appropriate_children +} + Index: openacs-4/packages/acs-tcl/tcl/apm-install-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-tcl/tcl/apm-install-procs.tcl,v diff -u -r1.2 -r1.3 --- openacs-4/packages/acs-tcl/tcl/apm-install-procs.tcl 27 Mar 2001 23:12:27 -0000 1.2 +++ openacs-4/packages/acs-tcl/tcl/apm-install-procs.tcl 30 Mar 2001 05:44:47 -0000 1.3 @@ -344,6 +344,9 @@ } else { set version_id [apm_package_install_version -callback $callback $package_key $version_name \ $version_uri $summary $description $description_format $vendor $vendor_uri $release_date] + + ns_log Notice "INSTALL-HACK-LOG-BEN: version_id is $version_id" + if { !$version_id } { # There was an error. apm_callback_and_log $callback "The package version could not be created." 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 -r1.1 -r1.2 --- openacs-4/packages/acs-tcl/tcl/db-query-dispatcher-procs.tcl 27 Mar 2001 23:12:27 -0000 1.1 +++ openacs-4/packages/acs-tcl/tcl/db-query-dispatcher-procs.tcl 30 Mar 2001 05:44:47 -0000 1.2 @@ -5,12 +5,10 @@ # # Ben Adida (ben@mit.edu) # -# STATE OF THIS FILE (3/17/2001) - BMA: -# Just function prototypes and some initial simple implementations to start clearing the field. -# Don't expect any of this to work just yet! -# +# STATE OF THIS FILE (3/29/2001) - BMA: +# This is starting to work, but isn't yet ready for actual dev work +# - # The Query Dispatcher is documented at http://openacs.org/ # This doesn't use the ad_proc construct, or any significant aD constructs, @@ -37,13 +35,17 @@ } proc db_rdbms_compatible_p {rdbms_test rdbms_pattern} { + ns_log Notice "QD/COMPATIBILITY = The RDBMS_TEST is [db_rdbms_get_type $rdbms_test] - [db_rdbms_get_version $rdbms_test]" + ns_log Notice "QD/COMPATIBILITY = The RDBMS_PATTERN is [db_rdbms_get_type $rdbms_pattern] - [db_rdbms_get_version $rdbms_pattern]" + # If the pattern is for all RDBMS, then yeah, compatible if {[empty_string_p [db_rdbms_get_type $rdbms_pattern]]} { return 1 } # If the RDBMS types are not the same, we have a problem if {[db_rdbms_get_type $rdbms_test] != [db_rdbms_get_type $rdbms_pattern]} { + ns_log Notice "QD - compatibility - RDBMS types are different!" return 0 } @@ -58,6 +60,7 @@ return 1 } + ns_log Notice "QD - compatibility - version numbers are bad!" return 0 } @@ -78,27 +81,27 @@ # The Accessor procs proc db_fullquery_get_name {fullquery} { - return [list $fullquery 0] + return [lindex $fullquery 0] } proc db_fullquery_get_querytext {fullquery} { - return [list $fullquery 1] + return [lindex $fullquery 1] } proc db_fullquery_get_bind_vars {fullquery} { - return [list $fullquery 2] + return [lindex $fullquery 2] } proc db_fullquery_get_query_type {fullquery} { - return [list $fullquery 3] + return [lindex $fullquery 3] } proc db_fullquery_get_rdbms {fullquery} { - return [list $fullquery 4] + return [lindex $fullquery 4] } proc db_fullquery_get_load_location {fullquery} { - return [list $fullquery 5] + return [lindex $fullquery 5] } @@ -142,8 +145,15 @@ # Find the fully qualified name of the query proc db_fullquery_get_fullname {local_name {added_stack_num 1}} { + # 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]} { + return $local_name + } + # Get the proc name being executed. - set proc_name [info level [expr "$added_stack_num + 1"]] + set proc_name [info level [expr "-1 - $added_stack_num"]] # We check if we're running the special ns_ proc that tells us # whether this is an URL or a Tcl proc. @@ -167,10 +177,19 @@ # Let's find out where this Tcl proc is defined!! # Get the first word, which is the Tcl proc regexp {^([^ ]*).*} $proc_name all proc_name - # ns_log Notice "QD = proc_name is -$proc_name-" + ns_log Notice "QD = proc_name is -$proc_name-" # We use the ad_proc construct!! # (woohoo, can't believe that was actually useful!) + + # First we check if the proc is there. If not, then we're + # probably dealing with one of the bootstrap procs, and so we just + # 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" + } + array set doc_elements [nsv_get api_proc_doc $proc_name] set url $doc_elements(script) @@ -186,6 +205,9 @@ # We need to remove packages. regexp {^packages\.(.*)} $url all rest + 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}" } @@ -268,10 +290,9 @@ } set one_query [lindex $result 0] - set one_query_name [lindex $result 1] - set parsing_state [lindex $result 2] + set parsing_state [lindex $result 1] - ns_log Notice "QD = loaded one query - $one_query_name" + ns_log Notice "QD = loaded one query - [db_fullquery_get_name $one_query]" # Store the query db_fullquery_internal_store_cache $one_query @@ -306,6 +327,7 @@ # Check if it's compatible at all! if {![db_rdbms_compatible_p [db_fullquery_get_rdbms $fullquery] [db_current_rdbms]]} { + ns_log Notice "QD = Query [db_fullquery_get_name $fullquery] is *NOT* compatible" return } @@ -406,8 +428,8 @@ # Parse the actual query from XML set one_query [db_fullquery_internal_parse_one_query_from_xml_node $one_query_xml] - # Return the query, the query name, and the parsing state - return [list [lindex $one_query 0] [lindex $one_query 1] $parsing_state] + # Return the query and the parsing state + return [list $one_query $parsing_state] } @@ -437,12 +459,15 @@ proc db_rdbms_parse_from_xml_node {rdbms_node} { # Check that it's RDBMS if {[ns_xml node name $rdbms_node] != "rdbms"} { + ns_log Notice "QD/PARSER = BAD RDBMS NODE!" return "" } # Get the type and version tags set type [ns_xml node getcontent [lindex [xml_find_child_nodes $rdbms_node type] 0]] set version [ns_xml node getcontent [lindex [xml_find_child_nodes $rdbms_node version] 0]] + ns_log Notice "QD/PARSER = RDBMS parser - $type - $version" + return [db_rdbms_create $type $version] } \ No newline at end of file