[Zope-dev] Accessing Gadfly via External Method

Paul Chung Chee Soong HCSCCS@prudential.com.my
Mon, 28 Jun 1999 10:28:59


>
> 1.  I can't create a External Method even though I had followed the
> description. Can anyone give an example of how to do it?


Did you create the Extensions directory in the Zope root folder?
try something simple like

def simple(self):
 return 'Goodmorning'

and call it from a DTML method like:

<!--# var simple -->

 ------------------------------------------------------------
Thanks for the above. Well, I have another problem with EM (external   
method). I can run my code normally when I was in the shell but when I   
tried to accecss it thru a DTML Method via a EM I got Attribute error.   
Here's an example:-

This is my python file (policy.py) in the Extensions dir.

#!/usr/local/bin/python

def ViewAll():
    import gadfly
    connection = gadfly.gadfly("policy",   
"/usr/local/src/Zope-2.0.0a1-src/Extensions/Policy")  <<<<-- error here
    cursor = connection.cursor()
    cursor.execute("select * from policy")
    recs = cursor.fetchall()
    connection.close()
    return recs

External Method: id : ViewAll, function: ViewAll, Module: policy   <--   
fine over here

DTML Method: <!--#var ViewAll-->

=====> Attribute Error on the connection line.


Any problem with my code?? Why? I tried <!--#var "ViewAll"--> with no   
error but the result is not that I wanted!


Thanks for any solution or suggestion,
Paul Chung