Running ExternalMethods using ZopeTestCase
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
Hello Tim! I have not looked into this yet but as you found out it may not be (easily) possible to run External Methods from INSTANCE_HOME/Extensions with ZTC. It does however work if you put your methods in a Product (Products/MyProduct/Extensions) as the products path is correct. hth, Stefan --On Mittwoch, 17. September 2003 17:20 +1000 Tim Edwards <Tim.Edwards@hwe.com.au> wrote:
Hi,
I am trying to run an ExternalMethod from a ZopeTestCase:
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
-- The time has come to start talking about whether the emperor is as well dressed as we are supposed to think he is. /Pete McBreen/
Tim Edwards wrote at 2003-9-17 17:20 +1000:
... 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".
I think this is a "testrunner.py" bug. When I remember right, someone had planned to fix it. Maybe, the current 2.6.2 "testrunner.py" is already fixed? Dieter
participants (3)
-
Dieter Maurer -
Stefan H. Holek -
Tim Edwards