I needed to send a bunch of emails via Zope today. I figured I would just use the python script I found on ZopeLabs... http://www.zopelabs.com/cookbook/991178206 ...but that appears to have a problem with email addresses containing hyphens. No good. So I pulled out one of my old dtml methods for sending mail and tried to stick a call to it inside a dtml-in loop. And I got stuck. How do I call the DTML Method? I tried calling it as: <dtml-call "method(arg1='test')">. Didn't like that. I'm calling from a DTML Document, which has its own namespace, so I figured the method would use that, so I tried <dtml-call "method">. This at least began executing the method, though it did give a KeyError on the data from the sequence. I gave up and stuffed the sendmail code inside the loop and called it good. But I'm still wondering how to make this work. Any clues? What have I missed? TIA, Howard Hansen http://howardsmusings.com/categories/zope
So I pulled out one of my old dtml methods for sending mail and tried to stick a call to it inside a dtml-in loop. And I got stuck. How do I call the DTML Method? I tried calling it as: <dtml-call "method(arg1='test')">. Didn't like that. I'm calling from a DTML Document, which has its own namespace, so I figured the method would use that, so I tried <dtml-call "method">. This at least began executing the method, though it did give a KeyError on the data from the sequence.
I'm not quite following exactly what you are doing, but in general if you want to call a dtml method from python (and from dml if you enclose the commands in double quotes), you'll have to pass the request and context objects as parameters as in print context.standard_html_header(context,request) Douwe
Thanks Douwe, your answer is very close to what I need. How can I call the DTML Method inside a DTML Document (or Method) using only dtml? THX ----- Original Message ----- From: <douwe@oberon.nl> To: "Howard Hansen" <zope@halfmagic.com>; <zope@zope.org> Sent: Monday, June 24, 2002 11:31 PM Subject: RE: [Zope] Calling a DTML Method with arguments
So I pulled out one of my old dtml methods for sending mail and tried to stick a call to it inside a dtml-in loop. And I got stuck. How do I call the DTML Method? I tried calling it as: <dtml-call "method(arg1='test')">. Didn't like that. I'm calling from a DTML Document, which has its own namespace, so I figured the method would use that, so I tried <dtml-call "method">. This at least began executing the method, though it did give a KeyError on the data from the sequence.
I'm not quite following exactly what you are doing, but in general if you want to call a dtml method from python (and from dml if you enclose the commands in double quotes), you'll have to pass the request and context objects as parameters as in
print context.standard_html_header(context,request)
Douwe
Thanks Douwe, your answer is very close to what I need. How can I call the DTML Method inside a DTML Document (or Method) using only dtml?
I try not to use DTML, so I'm quite sure: <dtml-var "dtmlMethod( _, REQUEST, Param=Value)"> should work though. Douwe
douwe@oberon.nl writes:
Thanks Douwe, your answer is very close to what I need. How can I call the DTML Method inside a DTML Document (or Method) using only dtml?
I try not to use DTML, so I'm quite sure:
<dtml-var "dtmlMethod( _, REQUEST, Param=Value)"> should work though. Almost:
<dtml-var "dtmlMethod(_.None,_, keyword_parameters_as_needed)"> In special cases, "_.None" will be replaces by a so called "client" object. Lookup order is: * keyword parameters * client attributes * "_" keys More details: <http://www.dieter.handshake.de/pyprojects/zope/book/chap3.html> Dieter
Danke Dieter, that works perfectly. And thanks for the link. I'm looking it over right now. Howard Hansen http://howardsmusings.com/categories/zope ----- Original Message ----- From: "Dieter Maurer" <dieter@handshake.de> To: <douwe@oberon.nl> Cc: "Howard Hansen" <zope@halfmagic.com>; <zope@zope.org> Sent: Tuesday, June 25, 2002 2:59 PM Subject: RE: [Zope] Calling a DTML Method with arguments
douwe@oberon.nl writes:
Thanks Douwe, your answer is very close to what I need. How can I call the DTML Method inside a DTML Document (or Method) using only dtml?
I try not to use DTML, so I'm quite sure:
<dtml-var "dtmlMethod( _, REQUEST, Param=Value)"> should work though. Almost:
<dtml-var "dtmlMethod(_.None,_, keyword_parameters_as_needed)">
In special cases, "_.None" will be replaces by a so called "client" object.
Lookup order is:
* keyword parameters
* client attributes
* "_" keys
More details:
<http://www.dieter.handshake.de/pyprojects/zope/book/chap3.html>
Dieter
participants (3)
-
Dieter Maurer -
douwe@oberon.nl -
Howard Hansen