<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=us-ascii">
<META content="MSHTML 6.00.2900.3243" name=GENERATOR></HEAD>
<BODY
style="WORD-WRAP: break-word; webkit-nbsp-mode: space; webkit-line-break: after-white-space">
<DIV dir=ltr align=left><FONT face=Arial color=#0000ff size=2><SPAN
class=999473118-17012008>Thanks David,</SPAN></FONT></DIV>
<DIV dir=ltr align=left><FONT face=Arial color=#0000ff size=2><SPAN
class=999473118-17012008></SPAN></FONT> </DIV>
<DIV dir=ltr align=left><FONT face=Arial color=#0000ff size=2><SPAN
class=999473118-17012008>Yes, that does work. I am trying to keep the
persistence machinery in the persistent classes themselves. Notice with
the subsequent statement </SPAN></FONT></DIV>
<DIV dir=ltr align=left><FONT face=Arial color=#0000ff size=2><SPAN
class=999473118-17012008></SPAN></FONT> </DIV>
<DIV dir=ltr align=left><FONT face=Arial color=#0000ff size=2><SPAN
class=999473118-17012008>
newuser.setColor('red')</SPAN></FONT></DIV>
<DIV dir=ltr align=left><FONT face=Arial color=#0000ff size=2><SPAN
class=999473118-17012008></SPAN></FONT> </DIV>
<DIV dir=ltr align=left><FONT face=Arial color=#0000ff size=2><SPAN
class=999473118-17012008>----------------------------------------</SPAN></FONT></DIV>
<DIV dir=ltr align=left><FONT face=Arial color=#0000ff size=2><SPAN
class=999473118-17012008>class User(Persistent):</SPAN></FONT></DIV>
<DIV dir=ltr align=left><FONT face=Arial color=#0000ff size=2><SPAN
class=999473118-17012008>...</SPAN></FONT></DIV>
<DIV dir=ltr align=left><FONT face=Arial color=#0000ff size=2><SPAN
class=999473118-17012008> def setColor(self,
color):<BR>
self.color.setColor(color)<BR>
#self._p_changed = True<BR>
transaction.commit()</SPAN></FONT></DIV>
<DIV dir=ltr align=left><FONT face=Arial color=#0000ff size=2><SPAN
class=999473118-17012008></SPAN></FONT> </DIV>
<DIV dir=ltr align=left><FONT face=Arial color=#0000ff size=2><SPAN
class=999473118-17012008>the _p_changed should be set (implicitly), and then all
changes fixed with the transaction.commit() in that method--this doesn't seem to
be the case. I can uncomment the _p_changed = True line in the setColor
method and get the desired result, but I don't see why this is required, after
all, the color attribute is a Persistent class in itself. I
suppose because the Persistent class was added in the
__setstate__ it has not fully been bootstrapped at this point and needs a
little help. (the _p_changed=True is not needed when color is a
bonafide attribute)</SPAN></FONT></DIV>
<DIV dir=ltr align=left><FONT face=Arial color=#0000ff size=2><SPAN
class=999473118-17012008></SPAN></FONT> </DIV>
<DIV dir=ltr align=left><FONT face=Arial color=#0000ff size=2><SPAN
class=999473118-17012008>One final observation: if I instead put the
self._p_changed = True statement in the setColor method of the Color class, it
doesn't produce the desired persistency. This is somehow related to the
bootstrapping mystery.</SPAN></FONT></DIV>
<DIV dir=ltr align=left><FONT face=Arial color=#0000ff size=2><SPAN
class=999473118-17012008></SPAN></FONT> </DIV>
<DIV dir=ltr align=left><FONT face=Arial color=#0000ff size=2><SPAN
class=999473118-17012008>Thanks,</SPAN></FONT></DIV>
<DIV dir=ltr align=left><FONT face=Arial color=#0000ff size=2><SPAN
class=999473118-17012008>Dave</SPAN></FONT></DIV>
<DIV class=OutlookMessageHeader lang=en-us dir=ltr align=left><FONT face=Arial
color=#0000ff size=2></FONT> </DIV>
<DIV class=OutlookMessageHeader lang=en-us dir=ltr align=left>
<HR tabIndex=-1>
<FONT face=Tahoma size=2><B>From:</B> David Binger
[mailto:dbinger@mems-exchange.org] <BR><B>Sent:</B> Thursday, January 17, 2008
1:23 PM<BR></FONT></DIV>
<DIV></DIV>
<DIV>You need to saved the user object with the color attribute.</DIV>
<DIV>The __setstate__ is just giving you the unsaved one every
time.</DIV>Add 'newuser._p_changed = 1' after the first
<DIV>assert statement below and it will be saved along with</DIV>
<DIV>your change to the Color instance.</DIV>
<DIV><BR>
<DIV>
<DIV>On Jan 17, 2008, at 11:21 AM, Mika, David P (GE, Research) wrote:</DIV><BR
class=Apple-interchange-newline>
<BLOCKQUOTE type="cite"><SPAN class=Apple-style-span
style="WORD-SPACING: 0px; FONT: 13px Arial; TEXT-TRANSFORM: none; COLOR: rgb(0,0,255); TEXT-INDENT: 0px; WHITE-SPACE: normal; LETTER-SPACING: normal; BORDER-COLLAPSE: separate; orphans: 2; widows: 2; webkit-border-horizontal-spacing: 0px; webkit-border-vertical-spacing: 0px; webkit-text-decorations-in-effect: none; webkit-text-size-adjust: auto; webkit-text-stroke-width: 0">
def test_2_setstate(self):<BR> print
'in test2'<BR> newuser =
self.userdb[self.id]<BR> # setstate
is called subsequently<BR> assert
hasattr(newuser, 'color')<BR> assert
newuser.getColor() == 'blue'<BR>
newuser.setColor('red')<BR> assert
newuser.getColor() ==
'red' </SPAN></BLOCKQUOTE></DIV><BR></DIV></BODY></HTML>