Hello, I have got problem with a try at using a previous Python-CGI dev in Zope (call it cgi_test.py for example). To do this, I am writing an external method, that import my cgi_test.py file. I rewrote my cgi_test.py to return the html page instead of printing the data to stdin. But, Zope does seem to like import in the external method. It is able to import the whole file (from cgi_test import * seems ok) but I it does not find the main() method when I call it from my external method (cgi.main()). When I am trying to import this method directly (from cgi_test import main), it does not work (method main is not found). Everything work fine when I simply run the external method from Python. So, I have got two questions: 1- How would you do such a task ? Is my method the best way to do what I need ? 2- What am I missing in Zope external method use ? Is there particular restriction on import (no pun intended !) ? Thank you in advance for your help. -- Mickaël
mikl@club-internet.fr wrote:
But, Zope does seem to like import in the external method.
I presume you meant "does not" here. Yes, this is true.
2- What am I missing in Zope external method use ? Is there particular restriction on import (no pun intended !) ?
I'm presuming that you are doing a module level import. Although I haven't attempted this yet, in Python you can move the import inside the function that you're calling. For example: def test_function(self): from foo import bar bar(self, 'ram', 'ewe') One day, I will get around to testing this myself (for that is the nature of my surname :-) ... Regards, Daryl Tester
participants (2)
-
Daryl Tester -
mikl@club-internet.fr