No registered users in community xowiki
in last 10 minutes
in last 10 minutes
[Xotcl] Differences between XOTcl 1 and XOTcl 2 setter and getter methods for slots?
From: Michael Aram <michael_at_aram.at>
Date: Mon, 12 Oct 2015 17:10:57 +0200
Dear XOTcl/NX/NSF community,
I am in the process of upgrading one of our OpenACS based systems to XOTcl
2 and stumbled over the following legacy code:
Class create Person -slots {
foreach e {username first_names last_name email etcetera} {
Attribute $e -default "" -proc assign {o var value} {$o changed_var
$var $value}
}
}
Person ad_instproc -private changed_var {var value} {} {
my instvar __changed_vars
lappend __changed_vars $var
my instvar $var
set $var $value
}
The intention of this not-so-pretty code mainly seems to be that the
Person->save method called by code like the following can recognize which
attributes have actually changed during the last request, and update the
database accordingly...
Person john
john last_name doe
john save
For some reason, now that I have upgraded the system to XOTcl 2, this does
not work anymore. The list __changed_vars is not updated (in the example
above, it would not contain last_name; for debugging purposes, I have put a
log statement into the "assign" proc, it seems that it does not get called.)
As the update process introduced many many other changes as well (compared
to the old and adapted OpenACS we had there), including changes in
xotcl-core, it could certainly be the case that this is simply a the
side-effect of some other change / or messed-up merge. So, my question is,
SHOULD this work anyway in the latest stable version of XOTcl 2, or did the
interface change?
Thanks for your help,
Michael :-)
Date: Mon, 12 Oct 2015 17:10:57 +0200
Dear XOTcl/NX/NSF community,
I am in the process of upgrading one of our OpenACS based systems to XOTcl
2 and stumbled over the following legacy code:
Class create Person -slots {
foreach e {username first_names last_name email etcetera} {
Attribute $e -default "" -proc assign {o var value} {$o changed_var
$var $value}
}
}
Person ad_instproc -private changed_var {var value} {} {
my instvar __changed_vars
lappend __changed_vars $var
my instvar $var
set $var $value
}
The intention of this not-so-pretty code mainly seems to be that the
Person->save method called by code like the following can recognize which
attributes have actually changed during the last request, and update the
database accordingly...
Person john
john last_name doe
john save
For some reason, now that I have upgraded the system to XOTcl 2, this does
not work anymore. The list __changed_vars is not updated (in the example
above, it would not contain last_name; for debugging purposes, I have put a
log statement into the "assign" proc, it seems that it does not get called.)
As the update process introduced many many other changes as well (compared
to the old and adapted OpenACS we had there), including changes in
xotcl-core, it could certainly be the case that this is simply a the
side-effect of some other change / or messed-up merge. So, my question is,
SHOULD this work anyway in the latest stable version of XOTcl 2, or did the
interface change?
Thanks for your help,
Michael :-)