I have some python code in various files in a subdir, and I want to be able to access some functions in that module as an External Method in python In python, I use it like 'from SomeFolder.SomeModule import some_func' but in my external method, when I put SomeFolder.SomeModule as the Module name in the external method dialog, I get an error that the Module could not be found even though SomeFolder/SomeModule.py is in the Extensions directory. Is it possible to create subdirectories of Zope/Extensions/ and use the dir.file syntax to access their contents? Thanks, John Hunter
Is it possible to create subdirectories of Zope/Extensions/ and use the dir.file syntax to access their contents?
As far as I remember, it is not possible to import modules from the Extensions directory (or any of its children I presume). You need to put the modules somewhere else appropriate. I use lib/python/Shared/<My Chosen Folder Name>/module.py hth tim
[Tim Hicks]
Is it possible to create subdirectories of Zope/Extensions/ and use the dir.file syntax to access their contents?
As far as I remember, it is not possible to import modules from the Extensions directory (or any of its children I presume). You need to put the modules somewhere else appropriate. I use lib/python/Shared/<My Chosen Folder Name>/module.py
You do have to make sure they are on the python path used by your zope python interpreter. One way is to put the location into a .pth file. This has come up a few times on the list. Cheers, Tom P
"Thomas" == Thomas B Passin <tpassin@mitretek.org> writes:
Thomas> [Tim Hicks] >> > Is it possible to create subdirectories of Zope/Extensions/ >> and use > the dir.file syntax to access their contents? >> >> As far as I remember, it is not possible to import modules from >> the Extensions directory (or any of its children I presume). >> You need to put the modules somewhere else appropriate. I use >> lib/python/Shared/<My Thomas> Chosen >> Folder Name>/module.py >> Thomas> You do have to make sure they are on the python path used Thomas> by your zope python interpreter. One way is to put the Thomas> location into a .pth file. This has come up a few times Thomas> on the list. I am still having trouble; perhaps someone can advise. /usr/local/Zope is my Zope install /usr/local/lib/python is the python dir used by Zope I put the directory ' SomeDir' and its contents in /usr/local/Zope/lib/python/Shared/.. I put SomeDir.pth in /usr/local/lib/python/site-packages/ and it has a single line which reads: /usr/local/Zope/lib/python/Shared As root (same shell that I use to start Zope), I can in a python shell
import SomeDir.SomeFile
I restarted zope and reloaded my web browser. I created an external method in zope and use the module name SomeDir.SomeFile where SomeFile.py resides in /usr/local/Zope/lib/python/Shared/SomeDir/, but I still get the Zope error: The specified module, SomeDir.SomeFile, couldn't be found What am I doing wrong? Thanks, John Hunter
participants (3)
-
John Hunter -
Thomas B. Passin -
Tim Hicks