Index: openacs-4/packages/xotcl-core/tcl/20-Ordered-Composite-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/xotcl-core/tcl/20-Ordered-Composite-procs.tcl,v diff -u -r1.8 -r1.9 --- openacs-4/packages/xotcl-core/tcl/20-Ordered-Composite-procs.tcl 2 Jan 2007 14:50:39 -0000 1.8 +++ openacs-4/packages/xotcl-core/tcl/20-Ordered-Composite-procs.tcl 6 Jan 2007 03:29:18 -0000 1.9 @@ -94,4 +94,46 @@ Class OrderedComposite::Child -instproc __after_insert {} {;} -} \ No newline at end of file + Class OrderedComposite::IndexCompare + OrderedComposite::IndexCompare instproc __compare {a b} { + set by [my set __orderby] + set x [$a set $by] + set y [$b set $by] + #my log "--value compare $x $y] => [my __value_compare $x $y 0]" + return [my __value_compare $x $y 0] + } + OrderedComposite::IndexCompare instproc __value_compare {x y def} { + set xp [string first . $x] + set yp [string first . $y] + if {$xp == -1 && $yp == -1} { + if {$x < $y} { + return -1 + } elseif {$x > $y} { + return 1 + } else { + return $def + } + } elseif {$xp == -1} { + set yh [string range $y 0 [expr {$yp-1}]] + return [my __value_compare $x $yh -1] + } elseif {$yp == -1} { + set xh [string range $x 0 [expr {$xp-1}]] + return [my __value_compare $xh $y 1] + } else { + set xh [string range $x 0 $xp] + set yh [string range $y 0 $yp] + #puts "xh=$xh yh=$yh" + if {$xh < $yh} { + return -1 + } elseif {$xh > $yh} { + return 1 + } else { + incr xp + incr yp + #puts "rest [string range $x $xp end] [string range $y $yp end]" + return [my __value_compare [string range $x $xp end] [string range $y $yp end] $def] + } + } + } +} + Index: openacs-4/packages/xotcl-core/tcl/generic-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/xotcl-core/tcl/generic-procs.tcl,v diff -u -r1.41 -r1.42 --- openacs-4/packages/xotcl-core/tcl/generic-procs.tcl 2 Jan 2007 14:50:39 -0000 1.41 +++ openacs-4/packages/xotcl-core/tcl/generic-procs.tcl 6 Jan 2007 03:29:18 -0000 1.42 @@ -485,10 +485,11 @@ {-sql ""} {-full_statement_name ""} } { - Return a set of instances of folder objects. If the ... + Return a set of instances of folder objects. + The container and contained objects are automatically + destroyed on cleanup of the connection thread } { - set __result [::xo::OrderedComposite new] - uplevel #1 [list $__result volatile] + set __result [::xo::OrderedComposite new -destroy_on_cleanup] #$__result proc destroy {} {my log "-- "; next} db_with_handle -dbn $dbn db {