[Zope] Running ExternalMethods using ZopeTestCase

Tim Edwards Tim.Edwards at hwe.com.au
Wed Sep 17 03:20:22 EDT 2003


Hi,

I am trying to run an ExternalMethod from a ZopeTestCase:

class TestSomeProduct(ZopeTestCase.ZopeTestCase):

    def afterSetUp(self):
        # Put SESSION object into REQUEST
        request = self.app.REQUEST
        sdm = self.app.session_data_manager
        request.set('SESSION', sdm.getSessionData())
        self.session = request.SESSION

    def testSomething(self):
        '''Test something'''
        print self.app.test2.company.id
        print self.app.test2.company._module
        print self.app.test2.company._function
        INSTANCE_HOME = insthome
        os.environ['INSTANCE_HOME'] = insthome
        print 'in the main module instance home is ' + INSTANCE_HOME
        print self.app.test2.company.filepath()
        print self.app.test2.company()

self.app.test2.company() is the External Method. The id, _module (Module
name) and _function (Function name) attributes are returning correct value,
as verified by the print statements. The problem seems to be that when I
actually call the method it can't find the module in the file system, to
verify this print self.app.test2.company.filepath() returns None. I have set
the instance home variable and environment variable and the print statements
above show the right values, in my case "C:\Program Files\Plone\Data".

I have traced this through some of the source code. The call to the external
method goes down into the __call__ function of
Products\ExternalMethod\ExternalMethod.py and from there it calls _getPath
from App\Extensions.py. This is where the cause of the problem seems to be:
the cause of the problem is that the instance_home variable loses it's value
- it becomes "C:\Program Files\Plone\Zope\lib\python\Testing". The
Intance_home environment variable still has the correct value. This causes
zope to be unable to find the external method.

Any help would be greatly appreciated

Tim Edwards



More information about the Zope mailing list