[Zope] zope: accessing zsql methods from external methods (1. 10.2 and 1.11pr1)

Brian Lloyd Brian@digicool.com
Mon, 10 May 1999 08:17:11 -0400


> I'm stumped. 
> 
> I need a simple example of how to get an external python 
> method to grok
> a working zsql query. 
> 
> I have a zsql query which works fine, called showcont, returning the
> entire contents of a small table.
> 
> I have a simple external method based on the hint on page 11 
> of the zsql
> methods user's guide which implies that an external method should get
> something useful back from showcont() - I've stripped it to the basics
> so I expect to get some horrible but familiar text back without adding
> any python complications - I just want this to work !!!
> 
> ===========testzsql.py in Extensions directory
> # testing external methods
> def test(self):
>      s = ''
>      for cont in showcont():
>           for contitem in cont:
>                s = s + contitem + '<BR>'        
>      return s
> =========
> The external method is loaded into the same folder as the zsql method
> and function test is called as testzsql.
> 
> I put a <!--#var testzsql--> into a dtml method and get...tracebacks.
> Basically, they all point to the fourth line - the showcont() 
> call seems
> to break. 

At first glance, I'd guess that the problem is that you are not
qualifying the showcont() method ( but I cant be sure without
seeing the actual traceback ).

Note that the "magical" namespace binding that happens in DTML does
*not* happen in external methods -- in other words, you need to 
qualify the method yourself: self.showcont() instead of just showcont(),
assuming that your showcont() method lives in the same folder.

Hope this helps!


Brian Lloyd        brian@digicool.com
Software Engineer  540.371.6909              
Digital Creations  http://www.digicool.com