[Zodb-checkins] CVS: ZODB4/src/zodb/code - function.py:1.6

Jeremy Hylton jeremy at zope.com
Tue May 20 16:07:54 EDT 2003


Update of /cvs-repository/ZODB4/src/zodb/code
In directory cvs.zope.org:/tmp/cvs-serv19336/zodb/code

Modified Files:
	function.py 
Log Message:
Refactor persistence api to use _p_changed only to mark an object as changed.

Use _p_deactivate() to turn an object into a ghost, and use the
keyword argument force=1 if you want to turn a modified object into a
ghost.  Several occurrences of the old interface have been updated.

This refactoring uncovered a number of subtle bugs in the persistence
C API.  The two chief problems were that the load function in the C
API struct did not set the state and that the functions return 0 for
error and 1 for success.  Regardless of whether these APIs are doing
the right thing, fix the code to use them correctly.

One downside of the new API is the C objects (BTrees) that override
_p_deactivate() have to deal with all the cruft for keyword
arguments.  Since BTrees only add a single line of extra code to
_p_deactivate(), it seems useful to provide a hook in the persistence
framework for this purpose.

Also:

If an object is in the changed state, don't call register() on its
data manager a second time.

Ignore state changes that result from setstate() being called.

Don't load an object's state to call __setstate__().

In BTrees check module, if an object has an oid, print that along with
its id().



=== ZODB4/src/zodb/code/function.py 1.5 => 1.6 ===
--- ZODB4/src/zodb/code/function.py:1.5	Wed Jan 15 14:54:11 2003
+++ ZODB4/src/zodb/code/function.py	Tue May 20 15:07:23 2003
@@ -149,7 +149,7 @@
 
             # XXX Is this sufficient?
             if self._v_side_effect:
-                self._pf_module._p_changed = 1
+                self._pf_module._p_changed = True
 
     def __getstate__(self):
         # If func_dict is empty, store None to avoid creating a dict




More information about the Zodb-checkins mailing list