[Zope] document_src returning evaluated dtml

Tim Hicks Tim Hicks" <tim@sitefusion.co.uk
Tue, 20 Feb 2001 20:10:57 -0000


I have asked this question before, but I am still no nearer finding a
solution.

I am running Zope 2.3.0 on a solaris box (although experience the same thing
under 2.2.2 on RH Linux 6.2).

I created a zclass which has base classes of 'ZObject, CatalogAwareBase,
ZDTMLDocument'.

In order to automatically reindex an instance when it is edited, I created
my own 'my_editForm' method within the zclass and assigned it to the edit
view.  This form was made by taking the html source of the standard edit
form page, and changing the static parts of the page (that refer to
modification time, size, textarea, id, title etc) for various dtml-var
inserts.  Here is an extract of the form as it is now.

  <FORM ACTION="my_edit" METHOD="POST">
    <TABLE CELLSPACING="2">
      <TR>
 <TH ALIGN="LEFT" VALIGN="TOP">Id</TH>
 <TD ALIGN="LEFT" VALIGN="TOP"><dtml-var id></TD>
      </TR>
      <TR>
 <TH ALIGN="LEFT" VALIGN="TOP"><EM>Title</EM></TH>
 <TD ALIGN="LEFT" VALIGN="TOP">
  <INPUT TYPE="TEXT" NAME="title" SIZE="40" VALUE="<dtml-var title>">
 </TD>
      </TR>
      <tr>
 <th align="left" valign="top">
        <em>Size</em>
        </th>
 <td align="left" valign="top">
        <dtml-var get_size> bytes
 </td>
      </tr>
      <tr>
 <th align="left" valign="top">
        <em>Last modified</em>
        </th>
 <td align="left" valign="top">
        <dtml-var bobobase_modification_time>
 </td>
      </tr>
      <TR>
 <TD COLSPAN="2" ALIGN="CENTER">
 <TEXTAREA NAME="data:text" WRAP="Off" COLS="<dtml-if dtpref_cols><dtml-var
dtpref_cols><dtml-else>80</dtml-if>" ROWS="<dtml-if dtpref_rows><dtml-var
dtpref_rows><dtml-else>12</dtml-if>"><dtml-var document_src></TEXTAREA>
 </TD>
      </TR>
      <TR>
 <TD align=left>
          <INPUT NAME=SUBMIT TYPE="SUBMIT" VALUE="Change">
 </TD>
 <TD align=left>
   <INPUT NAME=SUBMIT TYPE="SUBMIT" VALUE="Taller">
   <INPUT NAME=SUBMIT TYPE="SUBMIT" VALUE="Shorter">
   <INPUT NAME=SUBMIT TYPE="SUBMIT" VALUE="Wider">
   <INPUT NAME=SUBMIT TYPE="SUBMIT" VALUE="Narrower">
 </TD>
      </TR>
    </TABLE>
  </FORM>


As far as I can tell, the edit page seems to work fairly well. I'm pretty
sure that the correct 'size' and modification time gets inserted, and the
'id' and 'title' are definitely correct.  And, for the most part, the
<dtml-var document_src> works as expected as well.  However, if there is a
<dtml-call "RESPONSE.redirect('http://www.mysite.com')"> in the source of
the zclass instance, the redirect gets executed every time I try to simply
edit the instance!  Even more strangely, if the redirect call is within
other bits of dtml logic that evaluate to false (and thus result in the
redirect not being called when the instance is viewed), the redirect does
not occur when attempting to edit either.

In an effort to find a way around this, I have tried several things
including;

- using <dtml-var "document_src()">
- using <dtml-var "document_src()" html_quote>
- using <dtml-var "document_src(REQUEST,RESPONSE)">
- using <dtml-var "document_src(REQUEST,RESPONSE)"> <dtml-call
"REQUEST.set('Content-Type', 'text/html')">
- using <dtml-var "PrincipiaSearchSource()">
- using <dtml-call "REQUEST.set('thesource', _['document_src'])"><dtml-var
thesource>

in each case, the same thing happens [N.B. I'm not totally sure I've got the
syntax exactly correct for the last one].


So, I guess my question is, why is the document_src getting evaluated
instead of just sent the page as normal text?  This works properly when I
try to do it with a normal DTML Document; why does my zclass behave
differently?


Cheers for any help


Tim