[ZODB-Dev] subclassing Persistent in C

Jeremy Hylton jeremy at zope.com
Thu May 1 19:23:14 EDT 2003


On Thu, 2003-05-01 at 13:51, Nicholas Henke wrote:
> Hey all, I am attempting to subclass/extend the Persistent Class found
> in ZODB (cPersistence.c). I have looked through the BTrees code, as well
> as Extension.[ch] and come up with my 'PerWrapper' module and class. It
> _should_ be a transparent class that behaves exactly like Persistent,
> and apparently it does save one thing: it seg faults. I have attached a
> sample program that will trigger the segv every time in the exact same
> place.This is all using python2.2.2, ZODB3-3.1.1,

The example you extracted from your real code is incomplete, so it's
hard to see what is really happening.  (I don't know the ExtensionClass
details very well, so it helps to see all the code.)

It's hard to guess what you want PerWrapper to do, so it's not clear
what is wrong with it.  For one thing, you haven't defined a tp_dealloc
slot, so you can't actually create one.

Python 2.3b1 (#131, Apr 28 2003, 12:20:49) 
[GCC 2.96 20000731 (Red Hat Linux 7.3 2.96-113)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import PerWrapper
[49219 refs]
>>> PerWrapper.PerWrapper()
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
TypeError: Attempt to create instance of an abstract type

Jeremy





More information about the ZODB-Dev mailing list