[Zope-Checkins] CVS: StandaloneZODB/BTrees - BTreeModuleTemplate.c:1.20 BTreeTemplate.c:1.23 BucketTemplate.c:1.27 OIBTree.py:1.6 OOBTree.py:1.6 SetOpTemplate.c:1.12 SetTemplate.c:1.15 TreeSetTemplate.c:1.13 _IIBTree.c:1.5 _IOBTree.c:1.5 __init__.py:1.5

Jeremy Hylton jeremy@zope.com
Thu, 21 Feb 2002 16:41:17 -0500


Update of /cvs-repository/StandaloneZODB/BTrees
In directory cvs.zope.org:/tmp/cvs-serv17156/BTrees

Modified Files:
	BTreeModuleTemplate.c BTreeTemplate.c BucketTemplate.c 
	OIBTree.py OOBTree.py SetOpTemplate.c SetTemplate.c 
	TreeSetTemplate.c _IIBTree.c _IOBTree.c __init__.py 
Log Message:
Revert previous set of checkins!

The code was intended to be added to the Zope3 branch, not modified on
the trunk.




=== StandaloneZODB/BTrees/BTreeModuleTemplate.c 1.19 => 1.20 ===
  ****************************************************************************/
 
-#include "Python.h"
 #ifdef PERSISTENT
 #include "cPersistence.h"
-#include "cPersistenceAPI.h"
 
+/***************************************************************
+   The following are macros that ought to be in cPersistence.h */
+#ifndef PER_USE 
+
+#define PER_USE(O) \
+(((O)->state != cPersistent_GHOST_STATE \
+  || (cPersistenceCAPI->setstate((PyObject*)(O)) >= 0)) \
+ ? (((O)->state==cPersistent_UPTODATE_STATE) \
+    ? ((O)->state=cPersistent_STICKY_STATE) : 1) : 0)
+
+#define PER_ACCESSED(O) ((O)->atime=((long)(time(NULL)/3))%65536) 
+
+
+#endif
 /***************************************************************/
 
 #else
@@ -58,7 +70,7 @@
 
 typedef struct Bucket_s {
 #ifdef PERSISTENT
-  PyPersist_HEAD
+  cPersistent_HEAD
 #else
   PyObject_HEAD
 #endif
@@ -76,7 +88,7 @@
 
 typedef struct {
 #ifdef PERSISTENT
-  PyPersist_HEAD
+  cPersistent_HEAD
 #else
   PyObject_HEAD
 #endif
@@ -85,7 +97,7 @@
   BTreeItem *data;
 } BTree;
 
-staticforward PyTypeObject BTreeType;
+staticforward PyExtensionClass BTreeType;
 
 
 #define BTREE(O) ((BTree*)(O))
@@ -270,37 +282,44 @@
 BTREEITEMSTEMPLATE_C
 ;
 
-int
-init_persist_type(PyTypeObject *type)
-{
-    type->ob_type = &PyType_Type;
-    type->tp_getattro = PyPersist_TYPE->tp_getattro;
-    type->tp_setattro = PyPersist_TYPE->tp_setattro;
-
-    /* XXX for now */
-    type->tp_traverse = PyPersist_TYPE->tp_traverse;
-    type->tp_clear = PyPersist_TYPE->tp_clear;
-
-    return PyType_Ready(type);
-}
-
 void 
 INITMODULE (void)
 {
   PyObject *m, *d, *c;
 
-  sort_str = PyString_InternFromString("sort");
-  if (!sort_str)
-      return;
-  reverse_str = PyString_InternFromString("reverse");
-  if (!reverse_str)
-      return;
-  __setstate___str = PyString_InternFromString("__setstate__");
-  if (!__setstate___str)
+  UNLESS (sort_str=PyString_FromString("sort")) return;
+  UNLESS (reverse_str=PyString_FromString("reverse")) return;
+  UNLESS (items_str=PyString_FromString("items")) return;
+  UNLESS (__setstate___str=PyString_FromString("__setstate__")) return;
+
+  UNLESS (PyExtensionClassCAPI=PyCObject_Import("ExtensionClass","CAPI"))
       return;
 
+#ifdef PERSISTENT
+  if ((cPersistenceCAPI=PyCObject_Import("cPersistence","CAPI")))
+    {
+	BucketType.methods.link=cPersistenceCAPI->methods;
+	BucketType.tp_getattro=cPersistenceCAPI->getattro;
+	BucketType.tp_setattro=cPersistenceCAPI->setattro;
+
+	SetType.methods.link=cPersistenceCAPI->methods;
+	SetType.tp_getattro=cPersistenceCAPI->getattro;
+	SetType.tp_setattro=cPersistenceCAPI->setattro;
+
+	BTreeType.methods.link=cPersistenceCAPI->methods;
+	BTreeType.tp_getattro=cPersistenceCAPI->getattro;
+	BTreeType.tp_setattro=cPersistenceCAPI->setattro;
+
+	TreeSetType.methods.link=cPersistenceCAPI->methods;
+	TreeSetType.tp_getattro=cPersistenceCAPI->getattro;
+	TreeSetType.tp_setattro=cPersistenceCAPI->setattro;
+    }
+  else return;
+
   /* Grab the ConflictError class */
+
   m = PyImport_ImportModule("ZODB.POSException");
+
   if (m != NULL) {
   	c = PyObject_GetAttrString(m, "BTreesConflictError");
   	if (c != NULL) 
@@ -313,40 +332,31 @@
 	ConflictError=PyExc_ValueError;
   }
 
+#else
+  BTreeType.tp_getattro=PyExtensionClassCAPI->getattro;
+  BucketType.tp_getattro=PyExtensionClassCAPI->getattro;
+  SetType.tp_getattro=PyExtensionClassCAPI->getattro;
+  TreeSetType.tp_getattro=PyExtensionClassCAPI->getattro;
+#endif
+
+  BTreeItemsType.ob_type=&PyType_Type;
+
 #ifdef INTSET_H
   UNLESS(d = PyImport_ImportModule("intSet")) return;
   UNLESS(intSetType = PyObject_GetAttrString (d, "intSet")) return;
   Py_DECREF (d); 
 #endif
 
-  /* Initialize the PyPersist_C_API and the type objects. */
-  PyPersist_C_API = PyCObject_Import("Persistence.cPersistence", "C_API");
-  if (PyPersist_C_API == NULL)
-      return;
-
-  BTreeItemsType.ob_type = &PyType_Type;
-  init_persist_type(&BucketType);
-  init_persist_type(&BTreeType);
-  init_persist_type(&SetType);
-  init_persist_type(&TreeSetType);
-
   /* Create the module and add the functions */
-  m = Py_InitModule4("_" MOD_NAME_PREFIX "BTree", 
-		     module_methods, BTree_module_documentation,
-		     (PyObject *)NULL, PYTHON_API_VERSION);
+  m = Py_InitModule4("_" MOD_NAME_PREFIX "BTree", module_methods,
+		     BTree_module_documentation,
+		     (PyObject*)NULL,PYTHON_API_VERSION);
 
   /* Add some symbolic constants to the module */
   d = PyModule_GetDict(m);
-  if (PyDict_SetItemString(d, MOD_NAME_PREFIX "Bucket", 
-			   (PyObject *)&BucketType) < 0)
-      return;
-  if (PyDict_SetItemString(d, MOD_NAME_PREFIX "BTree", 
-			   (PyObject *)&BTreeType) < 0)
-      return;
-  if (PyDict_SetItemString(d, MOD_NAME_PREFIX "Set", 
-			   (PyObject *)&SetType) < 0)
-      return;
-  if (PyDict_SetItemString(d, MOD_NAME_PREFIX "TreeSet", 
-			   (PyObject *)&TreeSetType) < 0)
-      return;
+
+  PyExtensionClass_Export(d,MOD_NAME_PREFIX "Bucket", BucketType);
+  PyExtensionClass_Export(d,MOD_NAME_PREFIX "BTree", BTreeType);
+  PyExtensionClass_Export(d,MOD_NAME_PREFIX "Set", SetType);
+  PyExtensionClass_Export(d,MOD_NAME_PREFIX "TreeSet", TreeSetType);
 }


=== StandaloneZODB/BTrees/BTreeTemplate.c 1.22 => 1.23 ===
           && self->len == 1                            /* We have only one   */
           && ! SameType_Check(self, self->data->value) /* It's our child     */
-          && BUCKET(self->data->value)->po_oid == NULL /* It's in our record */
+          && BUCKET(self->data->value)->oid == NULL    /* It's in our record */
           )
       ) 
     if (PER_CHANGED(self) < 0) 
@@ -570,10 +570,10 @@
 static PyObject *
 BTree__p_deactivate(BTree *self, PyObject *args)
 {
-  if (self->po_state == UPTODATE && self->po_dm)
+  if (self->state==cPersistent_UPTODATE_STATE && self->jar)
     {
       if (_BTree_clear(self) < 0) return NULL;
-      self->po_state = GHOST;
+      self->state=cPersistent_GHOST_STATE;
     }
 
   Py_INCREF(Py_None);
@@ -619,7 +619,7 @@
       if (self->len == 1 
           && self->data->value->ob_type != self->ob_type
 #ifdef PERSISTENT
-          && BUCKET(self->data->value)->po_oid == NULL
+          && BUCKET(self->data->value)->oid == NULL
 #endif
           )
         {
@@ -731,9 +731,9 @@
         {
           if (! firstbucket) firstbucket=self->data->value;
 
-	  /* XXX what is this? */
-	  if (!PyObject_IsInstance(firstbucket, (PyObject *)
-				   (noval ? &SetType : &BucketType)))
+          UNLESS (ExtensionClassSubclassInstance_Check(
+                    firstbucket, 
+                    noval ? &SetType : &BucketType))
             {
               PyErr_SetString(PyExc_TypeError, 
                               "No firstbucket in non-empty BTree");
@@ -788,7 +788,7 @@
     UNLESS (s[i]==Py_None || PyTuple_Check(s[i]))
       return merge_error(-100, -100, -100, -100);
 
-  if (PyObject_IsInstance((PyObject *)self, (PyObject *)&BTreeType))
+  if (ExtensionClassSubclassInstance_Check(self, &BTreeType))
       r = _bucket__p_resolveConflict(OBJECT(&BucketType), s);
   else
       r = _bucket__p_resolveConflict(OBJECT(&SetType), s);
@@ -1238,7 +1238,11 @@
 BTree_dealloc(BTree *self)
 {
   _BTree_clear(self);
-  PyPersist_TYPE->tp_dealloc((PyObject *)self);
+
+  PER_DEL(self);
+
+  Py_DECREF(self->ob_type);
+  PyMem_DEL(self);
 }
 
 static int
@@ -1297,46 +1301,35 @@
   0,0,0,0,0,0,0,0,0,0,
   (inquiry)BTree_nonzero};
 
-static PyTypeObject BTreeType = {
-    PyObject_HEAD_INIT(NULL) /* PyPersist_Type */
-    0,					/* ob_size */
-    "Persistence.BTrees.OOBTree." MOD_NAME_PREFIX "BTree",		/* tp_name */
-    sizeof(BTree),			/* tp_basicsize */
-    0,					/* tp_itemsize */
-    (destructor)BTree_dealloc,		/* tp_dealloc */
-    0,					/* tp_print */
-    0,					/* tp_getattr */
-    0,					/* tp_setattr */
-    0,					/* tp_compare */
-    0,					/* tp_repr */
-    &BTree_as_number_for_nonzero,	/* tp_as_number */
-    0,					/* tp_as_sequence */
-    &BTree_as_mapping,			/* tp_as_mapping */
-    0,					/* tp_hash */
-    0,					/* tp_call */
-    0,					/* tp_str */
-    0,					/* tp_getattro */
-    0,					/* tp_setattro */
-    0,					/* tp_as_buffer */
-/* XXX need to define traverse and clear functions */
-    Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC |
-	    Py_TPFLAGS_BASETYPE, 	/* tp_flags */
-    0,					/* tp_doc */
-    0,	/* tp_traverse */
-    0,		/* tp_clear */
-    0,					/* tp_richcompare */
-    0,					/* tp_weaklistoffset */
-    0,					/* tp_iter */
-    0,					/* tp_iternext */
-    BTree_methods,			/* tp_methods */
-    0,					/* tp_members */
-    0,					/* tp_getset */
-    0,					/* tp_base */
-    0,					/* tp_dict */
-    0,					/* tp_descr_get */
-    0,					/* tp_descr_set */
-    0,					/* tp_dictoffset */
-    0,					/* tp_init */
-    0,					/* tp_alloc */
-    PyType_GenericNew,			/* tp_new */
+static PyExtensionClass BTreeType = {
+  PyObject_HEAD_INIT(NULL)
+  0,				/*ob_size*/
+  MOD_NAME_PREFIX "BTree",			/*tp_name*/
+  sizeof(BTree),		/*tp_basicsize*/
+  0,				/*tp_itemsize*/
+  /************* methods ********************/
+  (destructor) BTree_dealloc,/*tp_dealloc*/
+  (printfunc)0,			/*tp_print*/
+  (getattrfunc)0,		/*obsolete tp_getattr*/
+  (setattrfunc)0,		/*obsolete tp_setattr*/
+  (cmpfunc)0,			/*tp_compare*/
+  (reprfunc)0,			/*tp_repr*/
+  &BTree_as_number_for_nonzero,	/*tp_as_number*/
+  0,				/*tp_as_sequence*/
+  &BTree_as_mapping,	/*tp_as_mapping*/
+  (hashfunc)0,			/*tp_hash*/
+  (ternaryfunc)0,		/*tp_call*/
+  (reprfunc)0,			/*tp_str*/
+  (getattrofunc)0,
+  0,				/*tp_setattro*/
+  
+  /* Space for future expansion */
+  0L,0L,
+  "Mapping type implemented as sorted list of items", 
+  METHOD_CHAIN(BTree_methods),
+  EXTENSIONCLASS_BASICNEW_FLAG 
+#ifdef PERSISTENT
+  | PERSISTENT_TYPE_FLAG 
+#endif
+  | EXTENSIONCLASS_NOINSTDICT_FLAG,
 };


=== StandaloneZODB/BTrees/BucketTemplate.c 1.26 => 1.27 ===
 bucket__p_deactivate(Bucket *self, PyObject *args)
 {
-  if (self->po_state == UPTODATE && self->po_dm)
+  if (self->state==cPersistent_UPTODATE_STATE && self->jar)
     {
       if (_bucket_clear(self) < 0) return NULL;
-      self->po_state = GHOST;
+      self->state=cPersistent_GHOST_STATE;
     }
 
   Py_INCREF(Py_None);
@@ -1130,10 +1130,14 @@
 };
 
 static void
-bucket_dealloc(Bucket *self)
+Bucket_dealloc(Bucket *self)
 {
   _bucket_clear(self);
-  PyPersist_TYPE->tp_dealloc((PyObject *)self);
+
+  PER_DEL(self);
+
+  Py_DECREF(self->ob_type);
+  PyMem_DEL(self);
 }
 
 /* Code to access Bucket objects as mappings */
@@ -1160,11 +1164,8 @@
   static PyObject *format;
   PyObject *r, *t;
 
-  if (format == NULL) {
-      format = PyString_FromString(MOD_NAME_PREFIX "Bucket(%s)");
-      if (format == NULL)
-	  return NULL;
-  }
+  UNLESS (format) UNLESS (format=PyString_FromString(MOD_NAME_PREFIX "Bucket(%s)")) 
+    return NULL;
   UNLESS (t=PyTuple_New(1)) return NULL;
   UNLESS (r=bucket_items(self,NULL)) goto err;
   PyTuple_SET_ITEM(t,0,r);
@@ -1176,49 +1177,39 @@
   return NULL;
 }
 
-static PyTypeObject BucketType = {
-    PyObject_HEAD_INIT(NULL) /* PyPersist_Type */
-    0,					/* ob_size */
-    MOD_NAME_PREFIX "Bucket",		/* tp_name */
-    sizeof(Bucket),			/* tp_basicsize */
-    0,					/* tp_itemsize */
-    (destructor)bucket_dealloc,		/* tp_dealloc */
-    0,					/* tp_print */
-    0,					/* tp_getattr */
-    0,					/* tp_setattr */
-    0,					/* tp_compare */
-    (reprfunc)bucket_repr,		/* tp_repr */
-    0,					/* tp_as_number */
-    0,					/* tp_as_sequence */
-    &Bucket_as_mapping,			/* tp_as_mapping */
-    0,					/* tp_hash */
-    0,					/* tp_call */
-    0,					/* tp_str */
-    0,					/* tp_getattro */
-    0,					/* tp_setattro */
-    0,					/* tp_as_buffer */
-/* XXX need to define traverse and clear functions */
-    Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC |
-	    Py_TPFLAGS_BASETYPE, 	/* tp_flags */
-    0,					/* tp_doc */
-    0,	/* tp_traverse */
-    0,		/* tp_clear */
-    0,					/* tp_richcompare */
-    0,					/* tp_weaklistoffset */
-    0,					/* tp_iter */
-    0,					/* tp_iternext */
-    Bucket_methods,			/* tp_methods */
-    0,					/* tp_members */
-    0,					/* tp_getset */
-    0,					/* tp_base */
-    0,					/* tp_dict */
-    0,					/* tp_descr_get */
-    0,					/* tp_descr_set */
-    0,					/* tp_dictoffset */
-    0,					/* tp_init */
-    0,					/* tp_alloc */
-    PyType_GenericNew,			/* tp_new */
+static PyExtensionClass BucketType = {
+  PyObject_HEAD_INIT(NULL)
+  0,				/*ob_size*/
+  MOD_NAME_PREFIX "Bucket",			/*tp_name*/
+  sizeof(Bucket),		/*tp_basicsize*/
+  0,				/*tp_itemsize*/
+  /*********** methods ***********************/
+  (destructor) Bucket_dealloc,	/*tp_dealloc*/
+  (printfunc)0,			/*tp_print*/
+  (getattrfunc)0,		/*obsolete tp_getattr*/
+  (setattrfunc)0,		/*obsolete tp_setattr*/
+  (cmpfunc)0,			/*tp_compare*/
+  (reprfunc) bucket_repr,	/*tp_repr*/
+  0,				/*tp_as_number*/
+  0,				/*tp_as_sequence*/
+  &Bucket_as_mapping,		/*tp_as_mapping*/
+  (hashfunc)0,			/*tp_hash*/
+  (ternaryfunc)0,		/*tp_call*/
+  (reprfunc)0,			/*tp_str*/
+  (getattrofunc)0,		/*tp_getattro*/
+  0,				/*tp_setattro*/
+  
+  /* Space for future expansion */
+  0L,0L,
+  "Mapping type implemented as sorted list of items", 
+  METHOD_CHAIN(Bucket_methods),
+  EXTENSIONCLASS_BASICNEW_FLAG
+#ifdef PERSISTENT
+  | PERSISTENT_TYPE_FLAG 
+#endif
+  | EXTENSIONCLASS_NOINSTDICT_FLAG,
 };
+
 
 static int 
 nextBucket(SetIteration *i)


=== StandaloneZODB/BTrees/OIBTree.py 1.5 => 1.6 ===
 # We don't really want _ names in pickles, so update all of the __module__
 # references.
-##for o in globals().values():
-##    if hasattr(o, '__module__'):
-##        o.__module__=__name__
+for o in globals().values():
+    if hasattr(o, '__module__'):
+        o.__module__=__name__


=== StandaloneZODB/BTrees/OOBTree.py 1.5 => 1.6 ===
 # We don't really want _ names in pickles, so update all of the __module__
 # references.
-##for o in globals().values():
-##    print o
-##    if hasattr(o, '__module__'):
-##        o.__module__=__name__
-
-# XXX can't figure out why _reduce() won't call our __getstate__.
-
-import copy_reg
-
-def pickle_OOBTree(t):
-    return t.__class__, t.__getstate__()
-
-def unpickle_OOBTree(state):
-    obj = OOBTree.__new__(OOBTree, None)
-    obj.__setstate__(state)
-    return obj
-
-copy_reg.pickle(OOBTree, pickle_OOBTree)
+for o in globals().values():
+    if hasattr(o, '__module__'):
+        o.__module__=__name__


=== StandaloneZODB/BTrees/SetOpTemplate.c 1.11 => 1.12 ===
   i->position=0;
 
-  if (PyObject_IsInstance(s, (PyObject *)&BucketType))
+  if (ExtensionClassSubclassInstance_Check(s, &BucketType))
     {
       i->set = s;
       Py_INCREF(s);
@@ -82,7 +82,7 @@
 
       i->hasValue=1;
     }
-  else if (PyObject_IsInstance(s, (PyObject *)&SetType))
+  else if (ExtensionClassSubclassInstance_Check(s, &SetType))
     {
       i->set = s;
       Py_INCREF(s);
@@ -90,7 +90,7 @@
       i->next=nextSet;
       i->hasValue=0;
     }
-  else if (PyObject_IsInstance(s, (PyObject *)&BTreeType))
+  else if (ExtensionClassSubclassInstance_Check(s, &BTreeType))
     {
       i->set=BTree_rangeSearch(BTREE(s), NULL, 'i');
       UNLESS(i->set) return -1;
@@ -104,7 +104,7 @@
         i->next=nextTreeSetItems;
       i->hasValue=1;
     }
-  else if (PyObject_IsInstance(s, (PyObject *)&TreeSetType))
+  else if (ExtensionClassSubclassInstance_Check(s, &TreeSetType))
     {
       i->set=BTree_rangeSearch(BTREE(s), NULL, 'k');
       UNLESS(i->set) return -1;


=== StandaloneZODB/BTrees/SetTemplate.c 1.14 => 1.15 ===
 };
 
-static PyTypeObject SetType = {
-    PyObject_HEAD_INIT(NULL) /* PyPersist_Type */
-    0,					/* ob_size */
-    MOD_NAME_PREFIX "Set",		/* tp_name */
-    sizeof(Bucket),			/* tp_basicsize */
-    0,					/* tp_itemsize */
-    (destructor)bucket_dealloc,		/* tp_dealloc */
-    0,					/* tp_print */
-    0,					/* tp_getattr */
-    0,					/* tp_setattr */
-    0,					/* tp_compare */
-    (reprfunc)set_repr,			/* tp_repr */
-    0,					/* tp_as_number */
-    &set_as_sequence,			/* tp_as_sequence */
-    0,					/* tp_as_mapping */
-    0,					/* tp_hash */
-    0,					/* tp_call */
-    0,					/* tp_str */
-    0,					/* tp_getattro */
-    0,					/* tp_setattro */
-    0,					/* tp_as_buffer */
-/* XXX need to define traverse and clear functions */
-    Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC |
-	    Py_TPFLAGS_BASETYPE, 	/* tp_flags */
-    0,					/* tp_doc */
-    0,	/* tp_traverse */
-    0,		/* tp_clear */
-    0,					/* tp_richcompare */
-    0,					/* tp_weaklistoffset */
-    0,					/* tp_iter */
-    0,					/* tp_iternext */
-    Set_methods,			/* tp_methods */
-    0,					/* tp_members */
-    0,					/* tp_getset */
-    0,					/* tp_base */
-    0,					/* tp_dict */
-    0,					/* tp_descr_get */
-    0,					/* tp_descr_set */
-    0,					/* tp_dictoffset */
-    0,					/* tp_init */
-    0,					/* tp_alloc */
-    PyType_GenericNew,			/* tp_new */
+static PyExtensionClass SetType = {
+  PyObject_HEAD_INIT(NULL)
+  0,				/*ob_size*/
+  MOD_NAME_PREFIX "Set",			/*tp_name*/
+  sizeof(Bucket),		/*tp_basicsize*/
+  0,				/*tp_itemsize*/
+  /*********** methods ***********************/
+  (destructor) Bucket_dealloc,	/*tp_dealloc*/
+  (printfunc)0,			/*tp_print*/
+  (getattrfunc)0,		/*obsolete tp_getattr*/
+  (setattrfunc)0,		/*obsolete tp_setattr*/
+  (cmpfunc)0,			/*tp_compare*/
+  (reprfunc) set_repr,		/*tp_repr*/
+  0,				/*tp_as_number*/
+  &set_as_sequence,		/*tp_as_sequence*/
+  0,		                /*tp_as_mapping*/
+  (hashfunc)0,			/*tp_hash*/
+  (ternaryfunc)0,		/*tp_call*/
+  (reprfunc)0,			/*tp_str*/
+  (getattrofunc)0,		/*tp_getattro*/
+  0,				/*tp_setattro*/
+  
+  /* Space for future expansion */
+  0L,0L,
+  "Set implemented as sorted keys", 
+  METHOD_CHAIN(Set_methods),
+  EXTENSIONCLASS_BASICNEW_FLAG 
+#ifdef PERSISTENT
+  | PERSISTENT_TYPE_FLAG 
+#endif
+  | EXTENSIONCLASS_NOINSTDICT_FLAG,
 };
 
 static int 


=== StandaloneZODB/BTrees/TreeSetTemplate.c 1.12 => 1.13 ===
 };
 
-static PyTypeObject TreeSetType = {
-    PyObject_HEAD_INIT(NULL) /* PyPersist_Type */
-    0,					/* ob_size */
-    MOD_NAME_PREFIX "TreeSet",		/* tp_name */
-    sizeof(BTree),			/* tp_basicsize */
-    0,					/* tp_itemsize */
-    (destructor)BTree_dealloc,		/* tp_dealloc */
-    0,					/* tp_print */
-    0,					/* tp_getattr */
-    0,					/* tp_setattr */
-    0,					/* tp_compare */
-    0,					/* tp_repr */
-    &BTree_as_number_for_nonzero,	/* tp_as_number */
-    0,					/* tp_as_sequence */
-    &TreeSet_as_mapping,		/* tp_as_mapping */
-    0,					/* tp_hash */
-    0,					/* tp_call */
-    0,					/* tp_str */
-    0,					/* tp_getattro */
-    0,					/* tp_setattro */
-    0,					/* tp_as_buffer */
-/* XXX need to define traverse and clear functions */
-    Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC |
-	    Py_TPFLAGS_BASETYPE, 	/* tp_flags */
-    0,					/* tp_doc */
-    0,	/* tp_traverse */
-    0,		/* tp_clear */
-    0,					/* tp_richcompare */
-    0,					/* tp_weaklistoffset */
-    0,					/* tp_iter */
-    0,					/* tp_iternext */
-    TreeSet_methods,			/* tp_methods */
-    0,					/* tp_members */
-    0,					/* tp_getset */
-    0,					/* tp_base */
-    0,					/* tp_dict */
-    0,					/* tp_descr_get */
-    0,					/* tp_descr_set */
-    0,					/* tp_dictoffset */
-    0,					/* tp_init */
-    0,					/* tp_alloc */
-    PyType_GenericNew,			/* tp_new */
+static PyExtensionClass TreeSetType = {
+  PyObject_HEAD_INIT(NULL)
+  0,				/*ob_size*/
+  MOD_NAME_PREFIX "TreeSet",		/*tp_name*/
+  sizeof(BTree),		/*tp_basicsize*/
+  0,				/*tp_itemsize*/
+  /************* methods ********************/
+  (destructor) BTree_dealloc,   /*tp_dealloc*/
+  (printfunc)0,			/*tp_print*/
+  (getattrfunc)0,		/*obsolete tp_getattr*/
+  (setattrfunc)0,		/*obsolete tp_setattr*/
+  (cmpfunc)0,			/*tp_compare*/
+  (reprfunc)0,			/*tp_repr*/
+  &BTree_as_number_for_nonzero,	/*tp_as_number*/
+  0,				/*tp_as_sequence*/
+  &TreeSet_as_mapping,		/*tp_as_mapping*/
+  (hashfunc)0,			/*tp_hash*/
+  (ternaryfunc)0,		/*tp_call*/
+  (reprfunc)0,			/*tp_str*/
+  (getattrofunc)0,
+  0,				/*tp_setattro*/
+  
+  /* Space for future expansion */
+  0L,0L,
+  "Set implemented as sorted tree of items", 
+  METHOD_CHAIN(TreeSet_methods),
+  EXTENSIONCLASS_BASICNEW_FLAG 
+#ifdef PERSISTENT
+  | PERSISTENT_TYPE_FLAG 
+#endif
+  | EXTENSIONCLASS_NOINSTDICT_FLAG,
 };


=== StandaloneZODB/BTrees/_IIBTree.c 1.4 => 1.5 ===
 #include "intkeymacros.h"
 #include "intvaluemacros.h"
+#include "cPersistence.h"
 #ifndef EXCLUDE_INTSET_SUPPORT
 #include "BTree/intSet.h"
 #endif


=== StandaloneZODB/BTrees/_IOBTree.c 1.4 => 1.5 ===
 #include "intkeymacros.h"
 #include "objectvaluemacros.h"
+#include "cPersistence.h"
 #ifndef EXCLUDE_INTSET_SUPPORT
 #include "BTree/intSet.h"
 #endif


=== StandaloneZODB/BTrees/__init__.py 1.4 => 1.5 ===
+import ZODB
 
-##try: import intSet
-##except: pass
-##else: del intSet
+try: import intSet
+except: pass
+else: del intSet
 
-### Register interfaces
-##try: import Interface
-##except ImportError: pass # Don't register interfaces if no scarecrow
-##else:
-##    import Interfaces
-##    del Interfaces
-##    del Interface
+# Register interfaces
+try: import Interface
+except ImportError: pass # Don't register interfaces if no scarecrow
+else:
+    import Interfaces
+    del Interfaces
+    del Interface