[Zope] Newbie: need a simple example of external method
Hung Jung Lu
hung_jung_lu@adventure.com
Wed, 13 Oct 1999 14:15:29 -0700
Wow, thanks everyone. (Loren, too.)
This was much faster than wading through the tons of help files.
At some point we should make some document with searchable
index to help people finding this kind of information faster. Right
now the documentation is a little bit all over places and hard to
use.
..........
I have noticed that the external methods are only single-level deep.
That is, they have one-word names, e.g: myMethod. This might
be a problem in large-scale projects, where it is easy to run into
name conflicts.
Does anyone know whether internally zope uses the
"import myModule" and then internally assembles the
"myModule.myMethod()" call, or does it use
"from myModule import myFunction"?
I mean, has any zope users used method calls like
myObject.myInnerObject.myFurtherInnerObject.myMethod()?
I guess it's ok for Zope to use "from ... import ..." instead of
"import ...". It's just that I am very afraid of name collisions.
regards,
Hung Jung
-----Original Message-----
From: Pavlos Christoforou
[mailto:pavlos@gaaros.msrc.sunysb.edu]
Sent: Wednesday, October 13, 1999 1:57 PM
To: Hung Jung Lu
Cc: 'zope@zope.org'
Subject: Re: [Zope] Newbie: need a simple example of
external method
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