<!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>&nbsp;</DIV>
<DIV dir=ltr align=left><FONT face=Arial color=#0000ff size=2><SPAN 
class=999473118-17012008>Yes, that does work.&nbsp; I am trying to keep the 
persistence machinery in the persistent classes themselves.&nbsp; 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>&nbsp;</DIV>
<DIV dir=ltr align=left><FONT face=Arial color=#0000ff size=2><SPAN 
class=999473118-17012008>&nbsp;&nbsp; 
newuser.setColor('red')</SPAN></FONT></DIV>
<DIV dir=ltr align=left><FONT face=Arial color=#0000ff size=2><SPAN 
class=999473118-17012008></SPAN></FONT>&nbsp;</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>&nbsp;&nbsp; def setColor(self, 
color):<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
self.color.setColor(color)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
#self._p_changed = True<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
transaction.commit()</SPAN></FONT></DIV>
<DIV dir=ltr align=left><FONT face=Arial color=#0000ff size=2><SPAN 
class=999473118-17012008></SPAN></FONT>&nbsp;</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.&nbsp; 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.&nbsp; I 
suppose&nbsp;because the&nbsp;Persistent class was added in&nbsp;the 
__setstate__&nbsp;it has not fully been bootstrapped at this point and needs a 
little help.&nbsp; (the&nbsp;_p_changed=True is&nbsp;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>&nbsp;</DIV>
<DIV dir=ltr align=left><FONT face=Arial color=#0000ff size=2><SPAN 
class=999473118-17012008>One final observation:&nbsp; 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.&nbsp; 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>&nbsp;</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>&nbsp;</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&nbsp;every 
time.</DIV>Add 'newuser._p_changed = 1' &nbsp;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">&nbsp;&nbsp;&nbsp; 
  def test_2_setstate(self):<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print 
  'in test2'<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; newuser = 
  self.userdb[self.id]<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; # setstate 
  is called subsequently<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; assert 
  hasattr(newuser, 'color')<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; assert 
  newuser.getColor() == 'blue'<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
  newuser.setColor('red')<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; assert 
  newuser.getColor() == 
'red'&nbsp;&nbsp;</SPAN></BLOCKQUOTE></DIV><BR></DIV></BODY></HTML>