[Zope] Inserting headers and footers in response messages
Nitin Borwankar
nitin@borwankar.com
Sun, 25 Nov 2001 16:46:15 -0800
Bruce Eckel wrote:
>
> Inside an external method, I'm doing this:
>
> self.REQUEST.RESPONSE.setHeader('content-type',
> 'text/html')
> return '''<dtml-var standard_html_header>
> <h1 color="red">Invalid email address:
> please press your browser's 'back' key and correct
> it</h1>
> <dtml-var standard_html_footer>
> '''
>
> I'm not really surprised that standard_html_header and
> standard_html_footer aren't being expanded in the result, but I
> wonder if there's a way to do it?
Just guessing, but it would probably work if you did
self.REQUEST.RESPONSE.setHeader('content-type',
'text/html')
return <dtml-var standard_html_header>
+ ''' <h1 color="red">Invalid email address:
please press your browser's 'back' key and correct
it</h1>'''
+ <dtml-var standard_html_footer>
i.e. quote only the <h1>...</h1> part but not the two <dtml-var..>'s.
I am guessing the quoting is preventing it from rendering.
I am guessing again that the <dtml-var ...> will render inside a return
statement just as it
does outside it in a plain DTML document or method.
Of course a Python script that does the needful ( ie invoke
context.standard_html_header() + <h1> ...</h1> +
context.standard_html_footer() )
could be written and then invoked from inside the return statement.
This way it will render inside the Python script.
If you want to parametrise the method, pass in the <h1>...</h1> stuff as
a string parameter. This will effectively give you a Python script that
puts the standard header/footer around any message you want.
Nitin Borwankar.
nitin@borwankar.com
>
> Most current information can be found at:
> http://www.mindview.net/Etc/notes.html
> ===================
> Bruce Eckel http://www.BruceEckel.com
> Contains free electronic books: "Thinking in Java 2e" & "Thinking
> in C++ 2e"
> Please subscribe to my free newsletter -- just send any email to:
> join-eckel-oo-programming@earth.lyris.net
> My schedule can be found at:
> http://www.mindview.net/Calendar
> ===================
>
> _______________________________________________
> Zope maillist - Zope@zope.org
> http://lists.zope.org/mailman/listinfo/zope
> ** No cross posts or HTML encoding! **
> (Related lists -
> http://lists.zope.org/mailman/listinfo/zope-announce
> http://lists.zope.org/mailman/listinfo/zope-dev )
--
--
Nitin Borwankar
nitin@borwankar.com