[Zope-CMF] Examining portal_actions with the Zope app object from the Python interpreter
Phil Glaser
StillSmallVoice@DirectvInternet.com
Tue, 27 Aug 2002 17:11:12 -0400
Fellow Seekers!
At Alan's suggestion, and following the path of the yogis (or should I say
Zogies?) who have come before me, I am attempting to educate myself about
the intenerals of CMF by insantiating Zope from the Python command line and
examining with the objects directly. In particular, I'd like to see for
myself what's going on when the main_template does the following:
<tal:block tal:define="global actions
python:here.portal_actions.listFilteredActionsFor(here)">
So, here's what I did:
1. Turned off Zope
2. Fired up /usr/local/Zope/2-5-1/bin/python
3. Imported os, os.path, sys, string
4. Set apended '/usr/local/Zope/lib/python' to sys.path
5. imported Zope (if you don't turn off Zope as above, importing Zope won't
work here)
6. assigned Zope.app() to the local variable "app"
I then examined app's namespace (__dict__) and marveled at how beautiful and
cool Zope is that it lets you do this. Surely the bliss that all beings seek
was closer at hand and I rejoiced that my practice of the Middle Way of Zope
Zen was beginning to pay off. I then navigated through the object hierarchy,
starting with the app object, until I got down to the portal_skins object.
7. Assigned the portal_skins object to a local variable named "portal_skins"
8. Tried the following command:
portal_skins.portal_actions.listFilteredActionsFor(portal_skins.custom)
The error messages I got back indicate that I'm getting closer to the bliss
I am seeking on this journey, but that "don't know mind" was blocking my
path; here's what I got:
****************************************************************************
*******
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "/usr/local/zope/2-5-1/lib/python/Products/CMFCore/ActionsTool.py",
line 187, in listFilteredActionsFor
ec = createExprContext(folder, portal, object)
File "/usr/local/zope/2-5-1/lib/python/Products/CMFCore/Expression.py",
line 61, in createExprContext
object_url = object.absolute_url()
File "/usr/local/zope/2-5-1/lib/python/OFS/Traversable.py", line 48, in
absolute_url
return join([req['SERVER_URL']] + req._script + path, '/')
KeyError: SERVER_URL
****************************************************************************
*******
Obviously, because I'm not running the server in the usual way, there is
something that's missing from the context. What can I do to make this error
go away and get a result from listFilteredActionsFor() (and, hence, get
closer to The Unconditioned)?
Also, the Python instance here does not respond to the usual escapes as far
as editing the interpreter command line (e.g., backspace does not work
properly, Ctrl-P does not give me the previous command, etc.). Is there some
way to fix this? (I'm in Linux 7.2)
Many thanks!
Regards,
Phil
Philip Glaser
Principal and Software Architect
Sustainable Software Solutions, LLC
StillSmallVoice@DirectvInternet.com
www.sustainsoft.com
973-951-9522