[ZODB-Dev] subclassing Persistent in C

Nicholas Henke henken at seas.upenn.edu
Thu May 1 19:55:47 EDT 2003


On Thu, 2003-05-01 at 14:39, Jeremy Hylton wrote:
> 
> test.py says "from IndexedCatalog import PerWrapper".
> I don't see how that code would work.

Doh -- my fault there. That was just it's current home. It should be for
the standalone case 'import PerWrapper'

> 
> There's also the TypeError I reported.  I don't see how you could have
> created one of these objects, so I don't see how you could know there
> was a bug :-).

I guess the only way I tried using it was by using it as a baseclass to
a python class. It does work that way.

> 
> The BTrees code is probably the best example, but I don't understand all
> the ExtensionClass mechanism in ZODB3.  We may need to ask Jim Fulton,
> unless we can find some other ExtensionClass experts on the list.  This
> should all be much easier in ZODB4, because Persistent is just a type.

I will try to find the black magic in BTress. Unfortunately I will not
be able to move to ZODB4 anytime in the near future.

> 
> For the specific case of tp_dealloc, your dealloc function needs to call
> PER_DEL() before freeing the memory.

Hey -- there is something. Guess I should have read that
Extending/Embedding New Types section a bit more carefully. After adding
this, it looks to work just fine! BTW -- Do you know why the
BTree_dealloc does a "Py_DECREF(self->ob_type)" ?

> 
> There are lots of little details to get right, I'm sure.  The BTrees
> code does everything that is necessary, but may be hard to separate the
> necessary parts from the BTree-specific parts.

After adding the dealloc, it looks like I am really close -- just need
to run it through a bunch more tests. :)

Nic
-- 
Nicholas Henke
Penguin Herder & Linux Cluster System Programmer
Liniac Project - Univ. of Pennsylvania




More information about the ZODB-Dev mailing list