[Zope] Tricky (I think!) external method question...

Steven Sartorius ssartor@bellatlantic.net
Tue, 30 Oct 2001 14:14:59 -0500


Hi,

I'm a relatively experienced python programmer who's just recently gotten
into Zope.  I've downloaded the pdf of 'The Zope Book' and looked through
the various How-To's but I'm stuck on the following problem:

Starting from the top....

I have a DTML Document which is essentially a simple data input form.  The
'ACTION' attribute of the 'FORM' statement calls a python Script to clean up
and format the data.  As part of this, the Script calls a number of External
Methods, all of which are written in python.  I do this by using the
'container' binding (e.g. x = container.myExternalMethod()).  Some of these
External Methods in turn import various .py files from my personal python
directory which is totally separate and apart from where Zope/Extensions
lives in the filesystem.  In general all this works -- I get the results I
expect.  My problem comes from the one External Method that imports a .py
file that contains a subclassed Class.  The External Method looks like this:

import MySubClass
def aFunction(self,a,b,c):
    d = MySubClass.MySubClass(a,b,c)
    return d

MySubClass in turn looks like this:

import MyClass
class MySubClass(MyClass.MyClass):
    def __init__(self,a,b,c):
        """Do some initialization that differs from MyClass"""
        return d


The External Method above dies when it tries to create 'd'.  The traceback I
get from Zope says:

Error Type: TypeError
Error Value:  __init__() should return None

I'm stumped by this.  I think there is some sort of namespace confusion
going on but I'm not sure.  If anyone can shed any light on this (and save
some of my hair!) I'd appreciate it.

Thanks,

Steve