[Zope] Re: How to break up an external method over multiply source files
Andreas Jung wrote: --On Dienstag, 19. April 2005 11:25 Uhr +0200 Lucas Hofman [EMAIL PROTECTED] wrote: I have an external method a.py (in $INSTANCE_HOME/Extensions) that becomes to big to be in one python file. I have put some functions in b.py (also in $INSTANCE_HOME/Extensions) and want to use them from a.py. However 'import b' in a.py does not work. *Why* isn't it working? Errors? Tracebacks? Sorry, I finished typing a little to early. I get an importerror: Traceback (innermost last): Module ZPublisher.Publish, line 101, in publish Module ZPublisher.mapply, line 88, in mapply Module ZPublisher.Publish, line 39, in call_object Module Products.ExternalMethod.ExternalMethod, line 216, in __call__ Module Products.ExternalMethod.ExternalMethod, line 157, in reloadIfChanged Module Products.ExternalMethod.ExternalMethod, line 141, in getFunction Module App.Extensions, line 148, in getObject - __traceback_info__: ('/data/technology/Extensions/Import.py', 'Import') Module /data/technology/Extensions/Import.py, line 6, in ? ImportError: No module named Translate (Translate.py is in the same folder as Import.py) Lucas ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
[Zope] Re: How to break up an external method over multiply source files
Lucas Hofman wrote: Andreas Jung wrote: --On Dienstag, 19. April 2005 11:25 Uhr +0200 Lucas Hofman [EMAIL PROTECTED] wrote: I have an external method a.py (in $INSTANCE_HOME/Extensions) that becomes to big to be in one python file. I have put some functions in b.py (also in $INSTANCE_HOME/Extensions) and want to use them from a.py. However 'import b' in a.py does not work. *Why* isn't it working? Errors? Tracebacks? Sorry, I finished typing a little to early. I get an importerror: Traceback (innermost last): Module ZPublisher.Publish, line 101, in publish Module ZPublisher.mapply, line 88, in mapply Module ZPublisher.Publish, line 39, in call_object Module Products.ExternalMethod.ExternalMethod, line 216, in __call__ Module Products.ExternalMethod.ExternalMethod, line 157, in reloadIfChanged Module Products.ExternalMethod.ExternalMethod, line 141, in getFunction Module App.Extensions, line 148, in getObject - __traceback_info__: ('/data/technology/Extensions/Import.py', 'Import') Module /data/technology/Extensions/Import.py, line 6, in ? ImportError: No module named Translate (Translate.py is in the same folder as Import.py) In Import.py sys.path has the following value: ['/data/technology/Products/validation/validators/..', '/data/technology/lib/python', '/usr/local/zope272/lib/python/Zope/Startup', '/usr/local/zope272/lib/python', '/usr/local/lib/python23.zip', '/usr/local/lib/python2.3', '/usr/local/lib/python2.3/plat-linux2', '/usr/local/lib/python2.3/lib-tk', '/usr/local/lib/python2.3/lib-dynload', '/usr/local/lib/python2.3/site-packages'] (/data/technology in $INSTANCE_HOME). I would have expected /data/technology in sys.path. Lucas ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
[Zope] Re: How to break up an external method over multiply source files
Lucas Hofman wrote: Sorry, I finished typing a little to early. I get an importerror: Traceback (innermost last): Module ZPublisher.Publish, line 101, in publish Module ZPublisher.mapply, line 88, in mapply Module ZPublisher.Publish, line 39, in call_object Module Products.ExternalMethod.ExternalMethod, line 216, in __call__ Module Products.ExternalMethod.ExternalMethod, line 157, in reloadIfChanged Module Products.ExternalMethod.ExternalMethod, line 141, in getFunction Module App.Extensions, line 148, in getObject - __traceback_info__: ('/data/technology/Extensions/Import.py', 'Import') Module /data/technology/Extensions/Import.py, line 6, in ? ImportError: No module named Translate (Translate.py is in the same folder as Import.py) The solution was to set the path variable in zope.conf to $Instance/Extensions. Thanks, Lucas ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
[Zope] Re: How to break up an external method over multiply source files
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Andreas Jung wrote: | --On Dienstag, 19. April 2005 11:25 Uhr +0200 Lucas Hofman | [EMAIL PROTECTED] wrote: | | I have an external method a.py (in $INSTANCE_HOME/Extensions) that | becomes to big to be in one python file. | | I have put some functions in b.py (also in | $INSTANCE_HOME/Extensions) and want to use them from a.py. However | 'import b' in a.py does not work. | | *Why* isn't it working? Errors? Tracebacks? The file from which an ExternalMethod is instantiated is neither a script nor a module, which means that Python's import rules don't work for it. In response to the original question: I would put the 'b.py' file somewhere on the PYTHONPATH ($INSTANCE_HOME/lib/python would be a good choice); 'import b' will then work as expected. Tres. - -- === Tres Seaver[EMAIL PROTECTED] Zope Corporation Zope Dealers http://www.zope.com -BEGIN PGP SIGNATURE- Version: GnuPG v1.2.4 (GNU/Linux) Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org iD8DBQFCZQ2aGqWXf00rNCgRAtD/AKCC8E0O0mMEEF2eW0AGXf1aofWopgCfZIHr xvjVCTq8SS2IxRntZv77BbM= =0f3g -END PGP SIGNATURE- ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )