[Zope] Setting title in an external method
Greg Ward
gward@cnri.reston.va.us
Wed, 8 Mar 2000 12:10:07 -0500
Hi all --
A common idiom around here is to use an external method to process a
form and, if an error that the user can't fix occurs -- eg. you can't
view such-and-such an object because it doesn't exist, or you don't have
privileges -- use "return" to show them the contents of a DTML method
that explains the problem.
Here's a simple example:
def my_xm (self, REQUEST=None, RESPONSE=None):
# ... churn away, processing the form ...
return self.my_dtml (self, REQUEST, RESPONSE)
Here's the source for the "my_dtml" DTML method:
<dtml-var standard_html_header>
title: <b><dtml-var title></b><br>
document_title: <b><dtml-var document_title></b>
<p>
This is the <dtml-var document_id> Document
in the <dtml-var title_and_id> Folder.
</p>
<dtml-var standard_html_footer>
Both "my_xm" and "my_dtml" are in the root directory of an almost-fresh
Zope 2.1.4 installation.
The problem is that the "title" when I call "my_xm" (ie. the "Title:"
HTTP header and "<TITLE>" HTML tag) is just "Zope", which I presume is
the title *of the folder* containing the external method. Yuck. I want
the form result to have a title of its own, eg. "Error Viewing
Blah-blah".
What's the best way to do this? Possibilities that occur to me:
* redirect to the error-reporting DTML Method instead (but I like
to keep the number of redirects to a minimum)
* use a DTML Document instead of a Method (not sure if this will
work, and sometimes I really do want it to be a method -- eg.
it might be called from within a larger Document in some context)
* set some magical attribute of 'self' or 'RESPONSE' in the external
method; I tried "RESPONSE.setHeader ('Title', 'My Title')", but
that didn't work
Any other ideas? Thanks --
Greg
--
Greg Ward - software developer gward@cnri.reston.va.us
Corporation for National Research Initiatives
1895 Preston White Drive voice: +1-703-620-8990
Reston, Virginia, USA 20191-5434 fax: +1-703-620-0913