[Zope] external and sql methods

Anthony Baxter Anthony Baxter <anthony@interlink.com.au>
Wed, 04 Aug 1999 20:00:31 +1000


>>> ainis wrote
> Is there any way to call sql method from external method?

Yep - assuming you pass the sql method itself to the external method as
'meth', and it's set up as:
arguments: 
   name
body of method:
   select accountid, groupid
   from account_table
   where
   name = <!--#sqlvar name type=string-->

then your ext. method could be like

def ext1(meth):
  res=meth(name="fred")
  for r in res:
     # here, you iterate through the list of results.
     # normally a result will simply be an instance of
     # a dumb class with attributes set to the results,
     # eg:
     dosomethingwith(r.accountid, r.groupid)

hope this helps,
Anthony