[Zope3-checkins] CVS: ZODB4/Persistence/BTrees - BucketTemplate.c:1.19 BTreeTemplate.c:1.44 BTreeModuleTemplate.c:1.12

Jeremy Hylton jeremy@zope.com
Wed, 9 Oct 2002 18:41:33 -0400


Update of /cvs-repository/ZODB4/Persistence/BTrees
In directory cvs.zope.org:/tmp/cvs-serv29649/Persistence/BTrees

Modified Files:
	BucketTemplate.c BTreeTemplate.c BTreeModuleTemplate.c 
Log Message:
Eliminate BasePersistent!

Python 2.2 has peculiar rules about whether a type's instances should
have an __dict__, which have been fixed in 2.3.  The new rules make
the BasePersistent unnecessary, because Persistent does not need to
explicitly create an __dict__.

There is a vast simplification to the code by eliminating
BasePersistent and the corresponding C type.  All C code uses a single
type (PyPersist_TYPE) and struct (PyPersistObject *).  Yay!

But we've still got to support Python 2.2 (bummer) and it's two big a
change to make some version of 2.2 behave like 2.3.  So we still need
some sort of hack to make this all work with 2.2.  The answer is a
persistent meta class that creates the __dict__ for us.

The change has fairly broad changes to the Persistence package,
because the Python code already used PersistentMetaClass for
persistent clas support.  Rename that meta class to
PersistentClassMetaClass, which is descriptive but too verbose.  (Then
again all the names are too verbose.)



=== ZODB4/Persistence/BTrees/BucketTemplate.c 1.18 => 1.19 ===
--- ZODB4/Persistence/BTrees/BucketTemplate.c:1.18	Thu Aug  8 17:50:08 2002
+++ ZODB4/Persistence/BTrees/BucketTemplate.c	Wed Oct  9 18:41:32 2002
@@ -1455,7 +1455,7 @@
     if (self->ob_type == &BucketType)
 	assert(self->ob_type->tp_dictoffset == 0);
 
-    err = PyPersist_BASE_TYPE->tp_traverse((PyObject *)self, visit, arg);
+    err = PyPersist_TYPE->tp_traverse((PyObject *)self, visit, arg);
     if (err)
 	goto Done;
 
@@ -1496,7 +1496,7 @@
 int
 bucket_tp_clear(Bucket *self)
 {
-    PyPersist_BASE_TYPE->tp_clear((PyObject *)self);
+    PyPersist_TYPE->tp_clear((PyObject *)self);
     if (self->po_state != GHOST)
 	_bucket_clear(self);
     return 0;


=== ZODB4/Persistence/BTrees/BTreeTemplate.c 1.43 => 1.44 ===
--- ZODB4/Persistence/BTrees/BTreeTemplate.c:1.43	Thu Aug  8 17:50:08 2002
+++ ZODB4/Persistence/BTrees/BTreeTemplate.c	Wed Oct  9 18:41:32 2002
@@ -1825,7 +1825,7 @@
     if (self->ob_type == &BTreeType)
 	assert(self->ob_type->tp_dictoffset == 0);
 
-    err = PyPersist_BASE_TYPE->tp_traverse((PyObject *)self, visit, arg);
+    err = PyPersist_TYPE->tp_traverse((PyObject *)self, visit, arg);
     if (err)
 	goto Done;
 
@@ -1861,7 +1861,7 @@
 static int
 BTree_tp_clear(BTree *self)
 {
-    PyPersist_BASE_TYPE->tp_clear((PyObject *)self);
+    PyPersist_TYPE->tp_clear((PyObject *)self);
     if (self->po_state != GHOST)
 	_BTree_clear(self);
     return 0;


=== ZODB4/Persistence/BTrees/BTreeModuleTemplate.c 1.11 => 1.12 ===
--- ZODB4/Persistence/BTrees/BTreeModuleTemplate.c:1.11	Thu Aug  8 17:50:08 2002
+++ ZODB4/Persistence/BTrees/BTreeModuleTemplate.c	Wed Oct  9 18:41:32 2002
@@ -394,7 +394,7 @@
 init_persist_type(PyTypeObject *type)
 {
     type->ob_type = &PyType_Type;
-    type->tp_base = PyPersist_BASE_TYPE;
+    type->tp_base = PyPersist_TYPE;
 
     if (PyType_Ready(type) < 0)
 	return 0;