ZPT & passing around options...
Hello All... I have a problem that I haven't found a 'good' solution for. I use what I cann RPZN (Reverse Polish Zope Notation) when developing sites. RPZN is where you use one master template index_html in the root of your zope install. Thist master index_html file provides the layout for the entire site and includes (in my case) at least one reference like this: <div tal:content="structure here/content" class="content"> Content </div> This way each folder you create needs to only have a 'content' object (either a file, DTML Method or Document), which includes only the content for that folder. This makes adding to the site really easy. Want more content, add a folder, create a 'content' object and fill it in. The entire site look'n'feel is maintained in one place and that's /index_html. This has worked great for some time, until now. :-( Because of my design, in a Python script I need to call something like: return container.content(variable1="sometxt", var2=["text1","text2"]) This ends up calling the local content, without the surrounding site look'n'feel, <html> tags ... and the rest ... which is bad ... And ... calling index_html like so: return container.index_html(variable1="sometxt", var2=["text1","text2"]) (line may be wrapped) works fine wrt the site loook'n'feel and structure and all ... but the variables I pass into index_html get passed to the local content object, which is what I need to do. Anyone know how to do this? I spent some time looking around and I couldn't find an answer. Help! Thanks in advance ... I'd be happy to clarify anything above if it helps. --EAM
On Tue, Sep 10, 2002 at 12:56:01AM -0500, Edward Muller wrote:
Because of my design, in a Python script I need to call something like: return container.content(variable1="sometxt", var2=["text1","text2"])
This ends up calling the local content, without the surrounding site look'n'feel, <html> tags ... and the rest ... which is bad ...
And ... calling index_html like so: return container.index_html(variable1="sometxt", var2=["text1","text2"]) (line may be wrapped)
works fine wrt the site loook'n'feel and structure and all ... but the variables I pass into index_html get passed to the local content object, which is what I need to do.
I assume you meant to say "the variables ... do NOT get passed to the local content object, which is what I need to do" If that's what you want, one way you can do it is like so: Give your script the REQUEST parameter. In your script, do this: REQUEST.set('foo', 'spam spam spam spam') return context.index_html(REQUEST) Then you can refer to this variable in your content object like so: <p tal:content="request/foo"> </p> Or if it's sometimes in the request and sometimes in the context... <p tal:content="here/foo | request/foo"> </p> hope that helps, PW -- Paul Winkler "Welcome to Muppet Labs, where the future is made - today!"
Edward Muller writes:
... Because of my design, in a Python script I need to call something like: return container.content(variable1="sometxt", var2=["text1","text2"])
This ends up calling the local content, without the surrounding site look'n'feel, <html> tags ... and the rest ... which is bad ... Apparently, this case breaks your design principle ("content" does not have arguments).
I see two options: * extend your design principle: all "content" objects expect optional arguments. Inside your "index_html", you then have: <div tal:content="structure python:apply(here.content,(),options)"> and inside your script, you use return context.index_html(...) * You use "REQUEST" to pass the special variables to "content" and let it look there for its arguments. Dieter
participants (3)
-
Dieter Maurer -
Edward Muller -
Paul Winkler