Extension class problem

Terry Hancock hancock at anansispaceworks.com
Mon Apr 15 13:58:33 EDT 2002


Hi,
I'm running into something a little confusing. This must
be a fairly basic question, but I haven't been able to
find an answer to it in the documentation I've got (including
the online stuff, of course).

Anyway, I'm attempting a multiple-inheritance subclass
with some Zope objects (DTMLDocument  and Image if that
matters, which I doubt -- except that both are "Extension
Classes" rather than normal Python classes):

I need to bind some extra attributes and methods into
my object, so I made a helper class to hold those:

class NaryaContrib:
	def __init__(self, a, b, c):
		self.a = a
		self.b = b
		# ... simplified for brevity of course

Then I have the classes I actually want to use:

class GalleryArt(NaryaContrib, OFS.Image.Image):
	def __init__(self, a, b, c, id, title, file):
		NaryaContrib.__init__(self, a, b, c)
		OFS.Image.Image.__init__(self, id, title, file)
		#...

Except that that doesn't work -- this causes a runtime error
reminding me that an unbound method requires the first
argument to be the class instance. But it seems to me that
I've done that (i.e. the "self" should be a valid instance
since I've inherited from these classes (?) ).  At least
this seems to work for normal Python classes, when I test
it.

A little research reveals that OFS.Image.Image is an "extension
class" by virtue of inheriting from a basic extension class
in Zope, "Persistent".  My impression is that extension classes
impose some extra limitations, and I must be running into one
of them, but I can't figure out what to do about it.  Is there
a standard solution for this?  I probably just need a little
help finding the right place to look for help.

Thanks for any help,
Terry

-- 
------------------------------------------------------
Terry Hancock
hancock at anansispaceworks.com       
Anansi Spaceworks                 
http://www.anansispaceworks.com 
P.O. Box 60583                     
Pasadena, CA 91116-6583
------------------------------------------------------





More information about the Python-list mailing list