Index: openacs-4/packages/acs-object-management/sql/postgresql/acs-kernel-changes-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-object-management/sql/postgresql/Attic/acs-kernel-changes-create.sql,v diff -u -r1.3 -r1.4 --- openacs-4/packages/acs-object-management/sql/postgresql/acs-kernel-changes-create.sql 10 Dec 2009 22:24:27 -0000 1.3 +++ openacs-4/packages/acs-object-management/sql/postgresql/acs-kernel-changes-create.sql 11 Dec 2009 00:19:09 -0000 1.4 @@ -753,7 +753,7 @@ if p_null_p then v_column_spec := v_column_spec || '' set null''; else - v_column_spec := v_column_spec || '' delete''; + v_column_spec := v_column_spec || '' cascade''; end if; end if; Index: openacs-4/packages/acs-object-management/tcl/form-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-object-management/tcl/form-procs.tcl,v diff -u -r1.1 -r1.2 --- openacs-4/packages/acs-object-management/tcl/form-procs.tcl 27 Nov 2009 00:38:50 -0000 1.1 +++ openacs-4/packages/acs-object-management/tcl/form-procs.tcl 11 Dec 2009 00:19:09 -0000 1.2 @@ -21,7 +21,7 @@ } { set form_part [list [list ${object_view}_id:key(acs_object_id_seq)]] lappend form_part [list object_view:text(hidden) [list value $object_view]] - foreach attribute_id [db_list get_attribute_ids {}] { + foreach attribute_id [object_view::get_attribute_ids -object_view $object_view] { lappend form_part [form::element -object_view $object_view -attribute_id $attribute_id] } return $form_part @@ -30,14 +30,20 @@ ad_proc form::get_attributes { -object_view:required -array:required + -form } { + + if { ![info exists form] } { + set form $object_view + } + upvar $array local - foreach attribute_id [db_list get_attribute_ids {}] { + foreach attribute_id [object_view::get_attribute_ids -object_view $object_view] { object_view::attribute::get \ -object_view $object_view \ -attribute_id $attribute_id \ -array attr - set value [template::element::get_value $object_view $attr(view_attribute)] + set value [template::element::get_value $form $attr(view_attribute)] if { [llength [info procs ::template::data::to_sql::${attr(datatype)}]] } { set value [template::data::to_sql::${attr(datatype)} $value] } else { Index: openacs-4/packages/acs-object-management/tcl/form-procs.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-object-management/tcl/form-procs.xql,v diff -u -r1.1 -r1.2 --- openacs-4/packages/acs-object-management/tcl/form-procs.xql 27 Nov 2009 00:38:50 -0000 1.1 +++ openacs-4/packages/acs-object-management/tcl/form-procs.xql 11 Dec 2009 00:19:09 -0000 1.2 @@ -1,24 +1,6 @@ - - - select attribute_id - from acs_view_attributes - where object_view = :object_view - order by sort_order - - - - - - select attribute_id - from acs_view_attributes - where object_view = :object_view - order by sort_order - - - select aova.pretty_name, aova.sort_order, aa.datatype, aa.object_type, aova.view_attribute, Index: openacs-4/packages/acs-object-management/tcl/object-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-object-management/tcl/object-procs.tcl,v diff -u -r1.5 -r1.6 --- openacs-4/packages/acs-object-management/tcl/object-procs.tcl 10 Dec 2009 22:41:59 -0000 1.5 +++ openacs-4/packages/acs-object-management/tcl/object-procs.tcl 11 Dec 2009 00:19:09 -0000 1.6 @@ -189,14 +189,23 @@ ad_proc object::new_from_form { -object_view:required + -object_id + -form } { } { - set object_id [template::element::get_value $object_view ${object_view}_id] + if { ![info exists form] } { + set form $object_view + } + + if { ![info exists object_id] } { + set object_id [template::element::get_value $form \ + [template::element::get_value $form __key]] + } + form::get_attributes \ -object_view $object_view \ -array attributes -ns_log Notice "Huh? attributes: [array get attributes]" set object_type [object_view::get_element \ -object_view $object_view \ @@ -266,6 +275,7 @@ set view [object_type::get_root_view \ -object_type [object::get_object_type -object_id $object_id]] } + set names [object_view::get_attribute_names -object_view $view] db_1row get {} -column_array local_array } @@ -368,12 +378,23 @@ ad_proc object::update_from_form { -object_view:required + -object_id + -form } { } { - set object_id [template::element::get_value $object_view ${object_view}_id] + if { ![info exists form] } { + set form $object_view + } + + if { ![info exists object_id] } { + set object_id [template::element::get_value $form \ + [template::element::get_value $form __key]] + } + form::get_attributes \ -object_view $object_view \ + -form $form \ -array attributes set object_type [object_view::get_element \ Index: openacs-4/packages/acs-object-management/tcl/object-procs.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-object-management/tcl/object-procs.xql,v diff -u -r1.2 -r1.3 --- openacs-4/packages/acs-object-management/tcl/object-procs.xql 27 Nov 2009 00:38:50 -0000 1.2 +++ openacs-4/packages/acs-object-management/tcl/object-procs.xql 11 Dec 2009 00:19:09 -0000 1.3 @@ -28,9 +28,9 @@ - select * + select [join $names ,] from $view - where object_id = :object_id + where ${view}_id = :object_id Index: openacs-4/packages/acs-object-management/tcl/object-view-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-object-management/tcl/object-view-procs.tcl,v diff -u -r1.4 -r1.5 --- openacs-4/packages/acs-object-management/tcl/object-view-procs.tcl 27 Nov 2009 00:38:50 -0000 1.4 +++ openacs-4/packages/acs-object-management/tcl/object-view-procs.tcl 11 Dec 2009 00:19:09 -0000 1.5 @@ -73,6 +73,26 @@ return $view($element) } +ad_proc object_view::get_attribute_names { + -object_view:required +} { + Return a list of attribute names for the given view (doesn't include the + internal attributes like tree_sortkey) +} { + return [db_list -cache_pool acs_metadata -cache_key v::${object_view}::get_attr_names \ + get_attr_names {}] +} + +ad_proc object_view::get_attribute_ids { + -object_view:required +} { + Return a list of attribute ids for the given view (doesn't include the + internal attributes like tree_sortkey) +} { + return [db_list -cache_pool acs_metadata -cache_key v::${object_view}::get_attr_ids \ + get_attr_ids {}] +} + ad_proc object_view::flush_cache { -object_view:required } { Index: openacs-4/packages/acs-object-management/tcl/object-view-procs.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-object-management/tcl/object-view-procs.xql,v diff -u -r1.4 -r1.5 --- openacs-4/packages/acs-object-management/tcl/object-view-procs.xql 27 Nov 2009 00:38:50 -0000 1.4 +++ openacs-4/packages/acs-object-management/tcl/object-view-procs.xql 11 Dec 2009 00:19:09 -0000 1.5 @@ -25,4 +25,22 @@ + + + select view_attribute + from acs_view_attributes + where object_view = :object_view + order by sort_order + + + + + + select attribute_id + from acs_view_attributes + where object_view = :object_view + order by sort_order + + + Index: openacs-4/packages/acs-object-management/tcl/templating-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-object-management/tcl/Attic/templating-procs.tcl,v diff -u -r1.1 -r1.2 --- openacs-4/packages/acs-object-management/tcl/templating-procs.tcl 27 Nov 2009 00:38:50 -0000 1.1 +++ openacs-4/packages/acs-object-management/tcl/templating-procs.tcl 11 Dec 2009 00:19:09 -0000 1.2 @@ -39,7 +39,6 @@ ad_proc template::data::from_sql::date { value } { } { -ns_log Notice "Huh? value: $value" return [template::util::date::acquire ansi $value] }