Newbie: need a simple example of external method
Hi, I just subscribed to the mailing list, and in less than one day I got 60 messages, wow! This list surely is active. Can anyone give to me a simple example of a DTML document calling an external method? I mean, if I have a Python program myprogram.py: def myfunc(x): return 2*x; How do I proceed to use it in DTML, and how do I place it in the external methods folder? regards, Hung Jung
Go to the How-To's section of the Zope site: http://www.zope.org/Documentation/How-To The one about external methods is: http://www.zope.org/Documentation/How-To/ExternalMethods -- Loren
-----Original Message----- From: zope-admin@zope.org [mailto:zope-admin@zope.org]On Behalf Of Hung Jung Lu Sent: Wednesday, October 13, 1999 13:16 To: 'zope@zope.org' Subject: [Zope] Newbie: need a simple example of external method
Hi,
I just subscribed to the mailing list, and in less than one day I got 60 messages, wow! This list surely is active.
Can anyone give to me a simple example of a DTML document calling an external method? I mean, if I have a Python program
myprogram.py:
def myfunc(x): return 2*x;
How do I proceed to use it in DTML, and how do I place it in the external methods folder?
regards,
Hung Jung
_______________________________________________ Zope maillist - Zope@zope.org http://www.zope.org/mailman/listinfo/zope
(Related lists - please, no cross posts or HTML encoding!
To receive general Zope announcements, see: http://www.zope.org/mailman/listinfo/zope-announce
For developer-specific issues, zope-dev@zope.org - http://www.zope.org/mailman/listinfo/zope-dev )
This example shows how to call an external or an internal python method. The method convertDate(date) is located in a folder named utils off of the root. Technique 1: <!--#call "REQUEST.set('ThisDate',utils.convertDate(date))"--> Date is: <!--#var ThisDate --> <br> Technique 1 allows for the return value to be "stored" in a variable Technique 2: Date is: <!--#var "utils.convertDate(date)"--> Technique 2 simply uses the return value. Of course if your method doesn't return anything (called only for it's side effect) then technique 2 is modified to:<!--#call "utils.convertDate(date)"--> Hope this helps, DR
Welcome - On Wed, 13 Oct 1999, Hung Jung Lu wrote:
myprogram.py:
def myfunc(x): return 2*x;
How do I proceed to use it in DTML, and how do I place it in the external methods folder?
First go in your Zope management screen and select external method from the available object list. Add an id (lets say testit) add the function name (in your case myfunc) and then the python module file (which should exist in the Extensions directory in the main python distribution. In your case myprogram.py) click add and that's about it. In a DTML method you can call your function by simply calling: <dtml-var "testit(3)"> should print out 6 Pavlos
participants (4)
-
Dan Rusch -
Hung Jung Lu -
Loren Stafford -
Pavlos Christoforou