Accessing Basic Zope Objects
Hi All, I am having trouble accessing Zope Objects (importing them into my Python scripts). I am setting the PYTHONPATH INSTANCE_HOME environment variables in my startup scripts. While I can load these modules into Python at the command line I can't import them through Zope. Questions: How and where do you set Zope/Python environment variables so they can be able to find the Zope APIs? If I have other versions of Python (not included with Zope) running on the system can this cause the interpreter to become confused? Thanks in advance.
D. Bickle wrote at 2004-2-10 15:16 -0800:
I am having trouble accessing Zope Objects (importing them into my Python scripts).
Which Zope objects? Usually objects are not imported (but modules). Which Python scripts? "Script (Python)" (aka internal Python scripts) or External Methods? Which trouble? Exceptions? Which ones (with tracebacks!)? As you (hopefully) see, you must be *much* more precise in your problem reports... -- Dieter
On Wed, 11 Feb 2004, Dieter Maurer wrote:
D. Bickle wrote at 2004-2-10 15:16 -0800:
I am having trouble accessing Zope Objects (importing them into my Python scripts). By Zope object we typically refer to the Zope API (this is the convention used in the documentation).
Which Zope objects? Usually objects are not imported (but modules). Objects, modules, whatever. Zope objects in the API (Appendix B: API Reference)
Which Python scripts? "Script (Python)" (aka internal Python scripts) or External Methods? Both internal and external methods.
Which trouble? Exceptions? Which ones (with tracebacks!)? As previously stated Zope can't locate and therefore load the modules.
As you (hopefully) see, you must be *much* more precise in your problem reports... -- Dieter
On Wed, Feb 11, 2004 at 12:28:37PM -0800, D. Bickle wrote:
On Wed, 11 Feb 2004, Dieter Maurer wrote:
Which Python scripts? "Script (Python)" (aka internal Python scripts) or External Methods? Both internal and external methods.
Which trouble? Exceptions? Which ones (with tracebacks!)? As previously stated Zope can't locate and therefore load the modules.
Yes, but you have not given a *specific* example of what you're doing, along with the exact traceback. -- Paul Winkler http://www.slinkp.com Look! Up in the sky! It's PREFIX SNAZZY BOONDAWGAL HATTER! (random hero from isometric.spaceninja.com)
D. Bickle wrote at 2004-2-11 12:28 -0800:
... objects not importable ...
Which Python scripts? "Script (Python)" (aka internal Python scripts) or External Methods? Both internal and external methods.
The only requirement to import a module (and its content) from an External Method is that it (or a package chain containing it) is reachable via "sys.path". You can see the "sys.path" used by Zope in "Control_Panel --> Debug information". "sys.path" is setup from the "PYTHONPATH" environment variable. Zope extends it by its "lib/python" and (maybe) "$INSTANCE_HOME/lib/python". Python extends it by references to its runtime library and mechanisms documented in its "site.py" module. Import in internal Python scripts requires security declarations. This is documented in the Zope Developper guide and (partially) the "README" file in "Products/PythonScripts". When the security declarations are not there, you get an "Unauthorized" exception. -- Dieter
participants (3)
-
D. Bickle -
Dieter Maurer -
Paul Winkler