[Zope] Lookinf inside page templates from a script
Felix Ulrich-Oltean
felix@chaptereight.com
Mon, 12 Aug 2002 15:45:56 +0100
Hi
I'd like to get the names of all the macros in a pt and of all the
slots within each macro, but I'm getting guarded_item errors.
In PageTemplate.py, I have found pt_macros(), which returns a
dictionary with macro names as keys. Great so far. I can even print
pt_macros() and get a string representing the whole dictionary.
However, when I try to access the corresponding value so I can look
for the slots inside each macro, I get the error shown below. Is
there a way of gettting the macros and their slots from a script, or
do I have to write an external method / product?
Thanks
Felix.
Error Type: TypeError
Error Value: unsubscriptable object
Traceback (innermost last):
File
/usr/local/Zope-2.5.1-linux2-x86/lib/python/ZPublisher/Publish.py,
line 150, in publish_module
File
/usr/local/Zope-2.5.1-linux2-x86/lib/python/ZPublisher/Publish.py,
line 114, in publish
File /usr/local/Zope-2.5.1-linux2-x86/lib/python/Zope/__init__.py,
line 159, in zpublisher_exception_hook
(Object: Playground)
File
/usr/local/Zope-2.5.1-linux2-x86/lib/python/ZPublisher/Publish.py,
line 98, in publish
File
/usr/local/Zope-2.5.1-linux2-x86/lib/python/ZPublisher/mapply.py, line
88, in mapply
(Object: examineMacros.py)
File
/usr/local/Zope-2.5.1-linux2-x86/lib/python/ZPublisher/Publish.py,
line 39, in call_object
(Object: examineMacros.py)
File
/usr/local/Zope-2.5.1-linux2-x86/lib/python/Shared/DC/Scripts/Bindings.py,
line 252, in __call__
(Object: examineMacros.py)
File
/usr/local/Zope-2.5.1-linux2-x86/lib/python/Shared/DC/Scripts/Bindings.py,
line 283, in _bindAndExec
(Object: examineMacros.py)
File
/usr/local/Zope-2.5.1-linux2-x86/lib/python/Products/PythonScripts/PythonScript.py,
line 302, in _exec
(Object: examineMacros.py)
(Info: ({'script': <PythonScript instance at 8b76cd0>, 'context':
<Folder instance at 8aeb7e8>, 'container': <Folder instance at
8aeb7e8>, 'traverse_subpath': []}, (None,), {}, (None,)))
File Script (Python), line 8, in examineMacros.py
File /usr/local/zope/lib/python/AccessControl/ZopeGuards.py, line
90, in guarded_getitem
(Object: pt_macros)
TypeError: (see above)