Index: openacs-4/packages/acs-subsite/tcl/package-procs-oracle.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-subsite/tcl/package-procs-oracle.xql,v diff -u -r1.3 -r1.4 --- openacs-4/packages/acs-subsite/tcl/package-procs-oracle.xql 3 Aug 2001 21:09:20 -0000 1.3 +++ openacs-4/packages/acs-subsite/tcl/package-procs-oracle.xql 21 Nov 2001 05:20:31 -0000 1.4 @@ -128,7 +128,7 @@ start with t.object_type=:start_with connect by prior t.object_type = t.supertype) t where a.object_type = :object_type - and t.object_type = a.ancestor_type $storage_clause + and t.object_type = a.object_type $storage_clause order by type_level Index: openacs-4/packages/acs-subsite/tcl/package-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-subsite/tcl/package-procs.tcl,v diff -u -r1.5 -r1.6 --- openacs-4/packages/acs-subsite/tcl/package-procs.tcl 8 Oct 2001 23:56:19 -0000 1.5 +++ openacs-4/packages/acs-subsite/tcl/package-procs.tcl 21 Nov 2001 05:20:31 -0000 1.6 @@ -628,11 +628,50 @@ start with t.object_type=:start_with connect by prior t.object_type = t.supertype) t where a.object_type = :object_type - and t.object_type = a.ancestor_type $storage_clause + and t.object_type = a.object_type $storage_clause order by type_level"] } +ad_proc -private package_plsql_args { + { -function_name "NEW" } + object_type +} { + Generates a list of parameters expected to a plsql function + +
+
+ This replaces the annoying package_table_columns_for_type proc
+ which combines field names and arguments to PL/SQL, which
+ makes no sense when you're trying to abstract out the actual fields.
+
+ @author Ben Adida (ben@openforce)
+ @creation-date 11/2001
+
+ @param object_type The object type for which we are generating a list
+
+ @param function_name The function name which we're looking up
+} {
+
+ db_1row select_type_info {
+ select t.package_name
+ from acs_object_types t
+ where t.object_type = :object_type
+ }
+
+ # Get just the args
+ return [db_list select_object_type_param_list {
+ select args.argument_name
+ from user_arguments args
+ where args.position > 0
+ and args.object_name = upper(:function_name)
+ and args.package_name = upper(:package_name)
+ }]
+
+
+}
+
+
ad_proc -private package_table_columns_for_type {
object_type
} {
@@ -702,6 +741,7 @@
{ -creation_ip "" }
{ -package_name "" }
{ -var_list "" }
+ { -extra_vars "" }
{ -start_with "" }
{ -form_id "" }
{ -variable_prefix "" }
@@ -712,6 +752,7 @@
associated PL/SQL package new function.
@author Michael Bryzek (mbryzek@arsdigita.com)
+ @author Ben Adida (ben@openforce)
@creation-date 02/01/2001
@param creation_user The current user. Defaults to [ad_conn
@@ -727,6 +768,8 @@
values to pass to the constructor. Each pair is a list of two
elements: key => value
+ @param extra_vars an ns_set of extra vars
+
@param start_with The object type to start with when gathering
attributes for this object type
@@ -782,13 +825,27 @@
set creation_ip [ad_conn peeraddr]
}
}
+
+ lappend var_list [list creation_user $creation_user]
+ lappend var_list [list creation_ip $creation_ip]
# The first thing we need to do is select out the list of all
# the parameters that can be passed to this object type's new function.
# This will prevent us from passing in any parameters that are
# not defined
- foreach row [util_memoize "package_table_columns_for_type \"$object_type\""] {
- set real_params([string toupper [lindex $row 1]]) 1
+
+ # Change by Ben (OpenACS)
+ # This really should be more PL/SQL driven than table-field driven.
+ # Thus the change
+
+ #foreach row [util_memoize "package_table_columns_for_type \"$object_type\""] {
+ #set real_params([string toupper [lindex $row 1]]) 1
+ #ns_log Notice "DOTLRN: package_instantiate_object: real_params([string toupper [lindex $row 1]]) = 1"
+ #}
+
+ foreach arg [util_memoize "package_plsql_args \"$object_type\""] {
+ set real_params([string toupper $arg]) 1
+ ns_log Notice "DOTLRN: package_instantiate_object: real_params([string toupper $arg]) = 1"
}
# Use pieces to generate the parameter list to the new
@@ -805,26 +862,54 @@
if { ![info exists real_params([string toupper $key])] } {
# The parameter is not accepted as a parameter to the
# pl/sql function. Ignore it.
+ ns_log Notice "DOTLRN: package_instantiate_object: [string toupper $key] is ignored"
continue;
}
lappend pieces [list $key]
set param_array([string toupper $key]) 1
# Set the value for binding
set $key $value
+ ns_log Notice "DOTLRN: package_instantiate_object: set $key to $value"
}
- if { ![empty_string_p $form_id] } {
+ # Go through the extra_vars (ben - OpenACS)
+ if {! [empty_string_p $extra_vars] } {
+ for {set i 0} {$i < [ns_set size $extra_vars]} {incr i} {
+ set key [ns_set key $extra_vars $i]
+ set value [ns_set value $extra_vars $i]
+
+ if { ![info exists real_params([string toupper $key])] } {
+ # The parameter is not accepted as a parameter to the
+ # pl/sql function. Ignore it.
+ ns_log Notice "DOTLRN: package_instantiate_object: [string toupper $key] is ignored"
+ continue;
+ }
+ lappend pieces [list $key]
+ set param_array([string toupper $key]) 1
+ # Set the value for binding
+ set $key $value
+ ns_log Notice "DOTLRN: package_instantiate_object: set $key to $value"
+ }
+ }
+
+
+ if { ![empty_string_p $form_id]} {
# Append the values from the template form for each attribute
foreach row [package_object_attribute_list -start_with $start_with $object_type] {
set attribute [lindex $row 2]
+ ns_log Notice "DOTLRN: package_instantiate_object: getting attribute $attribute"
if { [info exists real_params([string toupper $attribute])] && ![info exists param_array([string toupper $attribute])] } {
+ ns_log Notice "DOTLRN: package_instantiate_object: $attribute is a real param, and not a param_array"
set param_array([string toupper $attribute]) 1
set $attribute [template::element::get_value $form_id "$variable_prefix$attribute"]
+
lappend pieces [list $attribute]
}
}
}
+ ns_log Notice "DOTLRN: package_instantiate_object: pieces are $pieces"
+
set object_id [db_exec_plsql create_object "
BEGIN
:1 := ${package_name}.new([plsql_utility::generate_attribute_parameter_call \
Index: openacs-4/packages/acs-subsite/tcl/relation-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-subsite/tcl/relation-procs.tcl,v
diff -u -r1.2 -r1.3
--- openacs-4/packages/acs-subsite/tcl/relation-procs.tcl 28 Aug 2001 19:03:28 -0000 1.2
+++ openacs-4/packages/acs-subsite/tcl/relation-procs.tcl 21 Nov 2001 05:20:31 -0000 1.3
@@ -27,6 +27,7 @@
ad_proc -public relation_add {
{ -form_id "" }
+ { -extra_vars "" }
{ -variable_prefix "" }
{ -creation_user "" }
{ -creation_ip "" }
@@ -40,10 +41,13 @@
constraint.
@author Michael Bryzek (mbryzek@arsdigita.com)
+ @author Ben Adida (ben@openforce)
@creation-date 1/5/2001
@param form_id The form id from templating form system
+ @param extra_vars An ns_set of extra variables
+
@param variable_prefix Only form elements that begin with the
specified prefix will be processed.
@@ -75,11 +79,14 @@
db_transaction {
+ ns_log Notice "DOTLRN: relation_add: var_list is $var_list"
+
set rel_id [package_instantiate_object \
-creation_user $creation_user \
-creation_ip $creation_ip \
-start_with "relationship" \
-form_id $form_id \
+ -extra_vars $extra_vars \
-variable_prefix $variable_prefix \
-var_list $var_list \
$rel_type]