Forum OpenACS Q&A: Error with move up in ETP

Collapse
Posted by Bill Millikin on
Using oacs 5.2.3b1 with included ETP, having a list of subpages, I want to be able to reorganize the list by using move up. I've been able to use that feature with previous versions, but suddenly not this version.

When I do that, I get the following error page:

-----

Database operation "dml" failed (exception ERROR, "ERROR: duplicate key violates unique constraint "cr_items_tree_sortkey_un"
")

ERROR: duplicate key violates unique constraint "cr_items_tree_sortkey_un"

SQL:
update cr_items
set tree_sortkey = '100000000000000000000011111001001000000000000000000000111000010000001100'
where item_id = '2177'

while executing
"ns_pg_bind dml nsdb1 {
update cr_items
set tree_sortkey = :new_sortkey
where item_id = :item_id
}"
("uplevel" body line 1)
invoked from within
"uplevel $ulevel [list ns_pg_bind $type $db $sql]"
("postgresql" arm line 2)
invoked from within
"switch $driverkey {
oracle {
return [uplevel $ulevel [list ns_ora $type $db $sql] $args]
}
..."
invoked from within
"db_exec dml $db $full_statement_name $sql"
("uplevel" body line 2)
invoked from within
"uplevel 1 $code_block "
invoked from within
"db_with_handle -dbn $dbn db {
db_exec dml $db $full_statement_name $sql
}"
(procedure "db_dml" line 100)
invoked from within
"db_dml update_key """
invoked from within
"if {[regsub "^$prev_sort_key" $tree_sortkey $sort_key new_sortkey] ||
[regsub "^$sort_key" $tree_sortkey $prev_sort_key new_sortkey]} {

..."
("uplevel" body line 3)
invoked from within
"uplevel 1 $code_block "
("1" arm line 1)
invoked from within
"switch $errno {
0 {
# TCL_OK
}
1 {
# TCL_ERROR
..."
("while" body line 20)
invoked from within
"while { [db_getrow $db $selection] } {
incr counter
if { [info exists array_val] } {
unset array_val
..."
("uplevel" body line 5)
invoked from within
"uplevel 1 $code_block "
invoked from within
"db_with_handle -dbn $dbn db {
set selection [db_exec select $db $full_statement_name $sql]

set counter 0
while { [db_getrow $..."
(procedure "db_foreach" line 36)
invoked from within
"db_foreach get_all_keys "" {

if {[regsub "^$prev_sort_key" $tree_sortkey $sort_key new_sortkey] ||
[regsub "^$sort_key" $tree_sortkey $pr..."
("uplevel" body line 3)
invoked from within
"uplevel 1 $transaction_code "
(procedure "db_transaction" line 39)
invoked from within
"db_transaction {

db_foreach get_all_keys "" {

if {[regsub "^$prev_sort_key" $tree_sortkey $sort_key new_sortkey] ||
[regsub "^$sort_key"..."
("uplevel" body line 26)
invoked from within
"uplevel {
# /packages/edit-this-page/www/etp-setup.tcl

ad_page_contract {
@author Luke Pond (mailto:dlpond@pobox.com)
@creation-date 2001-06-..."
(procedure "code::tcl::/var/lib/aolserver/allsouls/packages/edit-this-pa..." line 2)
invoked from within
"code::tcl::$__adp_stub"
invoked from within
"if { [file exists $__adp_stub.tcl] } {

# ensure that data source preparation procedure exists and is up-to-date
adp_init tcl $__adp_stub
..."
("uplevel" body line 3)
invoked from within
"uplevel {

if { [file exists $__adp_stub.tcl] } {

# ensure that data source preparation procedure exists and is up-to-date
adp_init t..."
(procedure "adp_prepare" line 2)
invoked from within
"adp_prepare "
(procedure "template::adp_parse" line 30)
invoked from within
"template::adp_parse [file root [ad_conn file]] {}"
(procedure "adp_parse_ad_conn_file" line 5)
invoked from within
"$handler"
("uplevel" body line 2)
invoked from within
"uplevel $code"
invoked from within
"ad_try {
$handler
} ad_script_abort val {
# do nothing
}"
invoked from within
"rp_serve_concrete_file [ad_conn file]"
(procedure "rp_serve_abstract_file" line 60)
invoked from within
"rp_serve_abstract_file $path"
(procedure "rp_internal_redirect" line 26)
invoked from within
"rp_internal_redirect $path"
(file "/var/lib/aolserver/allsouls/www/index.vuh" line 50)
invoked from within
"source [ad_conn file]"
(procedure "rp_handle_tcl_request" line 3)
invoked from within
"$handler"
("uplevel" body line 2)
invoked from within
"uplevel $code"
invoked from within
"ad_try {
$handler
} ad_script_abort val {
# do nothing
}"
invoked from within
"rp_serve_concrete_file [ad_conn file]"
(procedure "rp_serve_abstract_file" line 60)
invoked from within
"rp_serve_abstract_file -noredirect -nodirectory -extension_pattern ".vuh" "$root$prefix""
("uplevel" body line 3)
invoked from within
"uplevel $code"
invoked from within
"ad_try {
ad_conn -set path_info [string range $path [expr [string length $prefix] - 1] end]
rp_serve_abstract_file -noredirect -nodirectory -e..."

Collapse
Posted by Torben Brosten on

Hello Bill Millikin,

I see this too and do not have a direct solution. However, the following change automatically orders items in alphabetical sequence by default, which works (for me) for pages not in edit mode:

In file: packages/edit-this-page/tcl/etp-procs.tcl line 628 or so, there is:

    set limit_clause ""

Just after that, add:

# by default, sort by title                                                                                                
        set orderby title

I believe the order will not be alphabetical for some locales. Hopefully this works, at least as a temporary fix, until someone submits a patch.

Collapse
Posted by Bill Millikin on
Thanx, Torben!

This is a good way to handle it, except that my subpages and links are in a 'logical' sequence, so alpha isn't desireable.

I hope a response will come on this so I don't have to go back to an earlier version or something...

I don't know enough about TCL and so on to debug this on my own.

Collapse
Posted by Bill Millikin on
I have been looking at code, and the original code talks about it's OK that the keys are not unique for the sort of items, then in the PgSQL part - it complains about the keys not being unique..

If that's the error, would it be difficult to correct the flag in PgSQL so the keys can be non-unique?