[Zope] Namespace error in MIME/Sendmail

Dunigan, Craig craig.dunigan@esker.com
Wed, 20 Jun 2001 14:28:45 -0500


I hit one of those namespace/acquisition kind of things that let me know I'm
a long way from achieving the Zope Zen.  I want to give users an icon next
to a file link that will let them email the file as an attachment.  The
files will invariably live in a place not in the acquisition path of
document containing the link.  I pass the file path
("docname=/path_to_file/filename") and referring URL ("referrer=URL0") to a
DTML Document (called "SendMail") that looks like this:

<dtml-var standard_html_header>
<h2>Mailing the file <dtml-var docname>:</h2>
<h3>Referred from <dtml-var referrer></h3>

<form method="post" action="MailSender">
<table border=0 cellpadding=0 cellspacing=0>
<tr>
<td width=150>To address:</td><td><input type="text" name="send_to"
size=25></td>
</tr><tr>
<td>From address: </td><td><input type="text" name="send_from" size=25></td>
</tr><tr>
<td>Subject:</td><td><input type="text" name="subject" size=25></td>
</tr></table>
<p>Your message: <input type="textarea" name="message" wrap="soft" rows="25"
columns="50"></p>
<input type="hidden" name="SendDoc" value="<dtml-var docname>">
<input type="hidden" name="ReferUrl" value="<dtml-var referrer>">
<input type="submit" value="Send">
</form>
<dtml-var standard_html_footer>

MailSender (DMTL Document) looks like this:

<dtml-var standard_html_header>
<dtml-sendmail mailhost="MailHost">
To: <dtml-var send_to>
From: <dtml-var send_from>
Subject: <dtml-var subject>
<dtml-mime type=text/plain encode=7bit>

<dtml-var message>

<dtml-boundary type=application/octet-stream disposition=attachment
encode=base64><dtml-var "REQUEST.resolve_url(SendDoc).read()"></dtml-mime>
</dtml-sendmail>
<dtml-call expr="RESPONSE.redirect(ReferURL)">
<dtml-var standard_html_footer>

The first one works fine, but MailSender dies with a "Different namespace"
ValueError, and the following traceback:

Traceback (innermost last):
  File /opt/Zope/ZopeInst/lib/python/ZPublisher/Publish.py, line 223, in
publish_module
  File /opt/Zope/ZopeInst/lib/python/ZPublisher/Publish.py, line 187, in
publish
  File /opt/Zope/ZopeInst/lib/python/Zope/__init__.py, line 221, in
zpublisher_exception_hook
    (Object: CatalogAware)
  File /opt/Zope/ZopeInst/lib/python/ZPublisher/Publish.py, line 171, in
publish
  File /opt/Zope/ZopeInst/lib/python/ZPublisher/mapply.py, line 160, in
mapply
    (Object: MailSender)
  File /opt/Zope/ZopeInst/lib/python/ZPublisher/Publish.py, line 112, in
call_object
    (Object: MailSender)
  File /opt/Zope/ZopeInst/lib/python/OFS/DTMLDocument.py, line 189, in
__call__
    (Object: MailSender)
  File /opt/Zope/ZopeInst/lib/python/DocumentTemplate/DT_String.py, line
538, in __call__
    (Object: MailSender)
  File /opt/Zope/ZopeInst/lib/python/Products/MailHost/SendMailTag.py, line
187, in render
    (Object: MailHost)
  File /opt/Zope/ZopeInst/lib/python/Products/MIMETools/MIMETag.py, line
229, in render
  File /opt/Zope/ZopeInst/lib/python/DocumentTemplate/DT_Util.py, line 334,
in eval
    (Object: REQUEST.resolve_url(SendDoc).read())
    (Info: REQUEST)
  File &lt;string&gt;, line 0, in ?
  File /opt/Zope/ZopeInst/lib/python/ZPublisher/HTTPRequest.py, line 738, in
resolve_url
ValueError: (see above)

If it matters, both SendMail and MailSender live one folder above the root,
MailHost lives in the root.  What may be more significant is that the link
to SendMail lives in a DTML Method that lives at the same level as SendMail,
but is called into a DTML Document that may live anywhere.  The link itself
looks like this:  
<a href=SendMail?docname=<dtml-var
"_['sequence-item'][0]">&referrer=<dtml-var "URL0">>
and seems to pass the path and URL correctly.  

Since "SendDoc" came through in the traceback un-rendered, I assume that
somehow REQUEST.resolve_url can't read that variable, but why?  I also tried
REQUEST.SendDoc and REQUEST['SendDoc'] with identical results.  I'm probably
just confusing myself somewhere along the line, but I don't see it and I
need help!


Craig Dunigan
Web Programmer
Esker Software - Extending the Reach of Information
mailto:craig.dunigan@esker.com
Ph. 608.273.6000
Fax 608.273.8227
http://www.esker.com