Index: openacs-4/packages/xotcl-core/tcl/01-debug-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/xotcl-core/tcl/01-debug-procs.tcl,v diff -u -r1.22 -r1.23 --- openacs-4/packages/xotcl-core/tcl/01-debug-procs.tcl 24 Jul 2007 20:52:16 -0000 1.22 +++ openacs-4/packages/xotcl-core/tcl/01-debug-procs.tcl 3 Sep 2007 21:06:42 -0000 1.23 @@ -27,6 +27,8 @@ my requireNamespace namespace eval [self] $cmds } + # XOTcl 1.5 or newer supports slots. Here we have to + # emulate slots up to a certain point namespace eval ::xo { Class create ::xo::Attribute \ -parameter { @@ -40,16 +42,13 @@ pretty_name {pretty_plural ""} {datatype "text"} - {sqltype "text"} - {min_n_values 1} - {max_n_values 1} help_text validator } - } } else { namespace eval ::xo { + # create xo::Attribute as a subclass of the slot ::xotcl::Attribute Class create ::xo::Attribute \ -superclass ::xotcl::Attribute \ -parameter { @@ -58,22 +57,52 @@ pretty_name {pretty_plural ""} {datatype "text"} - {sqltype "text"} - {min_n_values 1} - {max_n_values 1} help_text validator } } } +namespace eval ::xo { + ::xo::Attribute instproc init {} { + my instvar name pretty_name + next + # provide a default pretty name for the attribute based on message keys + if {![info exists pretty_name]} { + set object_type [my domain] + if {[regexp {^::([^:]+)::} $object_type _ head]} { + set tail [namespace tail $object_type] + set pretty_name "#$head.$tail-$name#" + my log "--created pretty_name = $pretty_name" + } else { + error "Cannot determine automatically message key for pretty name. \ + Use namespaces for classes" + } + } + } +} + ::xotcl::Object instforward db_1row -objscope ::xotcl::Object instproc serialize {} { ::Serializer deepSerialize [self] } namespace eval ::xo { + proc slotobjects cl { + set so [list] + array set names "" + foreach c [concat $cl [$cl info heritage]] { + foreach s [$c info slots] { + set n [namespace tail $s] + if {![info exists names($n)]} { + lappend so $s + set names($n) $s + } + } + } + return $so + } ::xotcl::Class create ::xo::InstanceManager \ -instproc alloc args { set r [next]