[Zope] Accessing Content of a Page Template In Python
Dieter Maurer
dieter@handshake.de
Sat, 7 Dec 2002 21:12:18 +0100
Edward Pollard writes:
> ...
> If I have a text file in a directory, I can get the content from it from
> simply
> eg
> theContent = context.myFile
>
> How can I get the content out of a Page Template object?
You can use "document_src" and (maybe "PrincipiaSearchSource").
Both are protected by "View management screens".
I found this out with my "DocFinder" product:
<http://www.dieter.handshake.de/pyprojects/zope>
> A related problem I have is that I can call my script from the context
> of a file object, but not a Page Template.
> eg.
> myFile/myScript
>
> This allows me to access the file as 'context'. Now, I want this script
> to work on Files and Page Templates, but when I try to access
> myPageTemplate/myScript, it simply displays the rendered template. Is
> there any way to do something like this?
I fear that is because Page Templates bind the "traversal_subpath"
(like Python Scripts do).
Unlike with Python Scripts, they do not provide a way to customize
this behaviour.
I do not know why they bind "traversal_subpath". I think, it was
accidental (because the inherited "Script" does it).
Maybe, you file a collector report.
The effect of binding "traversal_subpath" is that URL traversal
stops at the object. The remaining URL path goes to the "traversal_subpath".
This is lost for Page Templates, as it is not exposed (you see, it feels
like a bug).
Dieter