[Zodb-checkins] CVS: Zope3/lib/python/Persistence - _persistent.py:1.1.2.5
Jim Fulton
jim@zope.com
Sun, 25 Nov 2001 19:23:19 -0500
Update of /cvs-repository/Zope3/lib/python/Persistence
In directory cvs.zope.org:/tmp/cvs-serv15283
Modified Files:
Tag: Zope-3x-branch
_persistent.py
Log Message:
Added comments in delicate setstate code.
Fixed setstate to propigate errors on setting state and to
keep the object in the ghost state.
=== Zope3/lib/python/Persistence/_persistent.py 1.1.2.4 => 1.1.2.5 ===
-def setstate(ob, dm, state=0):
+def setstate(ob, dm, state):
+ # Put in modified state so we don't mark ourselves as modified
+ # when our state is updated.
oset(ob, '_p_state', 1)
- dm.setstate(ob)
- oset(ob, '_p_state', state)
+
+ try:
+ # Get out data manager to updates us.
+ dm.setstate(ob)
+
+ # Now set the final state.
+ oset(ob, '_p_state', state)
+ except: # We are going to reraise!
+ # Something went wrong. We need to end up in the ghost state:
+ del ob._p_changed
+ raise