[Zope] Using database-connection from external methods
Pavlos Christoforou
pavlos@gaaros.msrc.sunysb.edu
Tue, 23 Mar 1999 15:25:27 -0500 (EST)
On Tue, 23 Mar 1999, John Eikenberry wrote:
>
> > Can external methods set/send back variables to the calling document/method?
>
> External methods can modify the current REQUEST object that the DTML uses
> from name resolution. If you are calling the external method from within
> the DTML, just use 'self.REQUEST' to access the current REQUEST object.
> Just create/set items on it like it was a dictionary...
>
> sekf.REQUEST['new_key'] = new_value
>
Alternatively your external method can return objects to the calling DTML.
for an external method spammethod you could do omething like:
class A:
pass
def spammethod(self,n):
a=[]
for i in range(n):
tmp=A()
tmp.no=i
a.append(tmp)
return a
Then in your DTML you can do something like
<!--# in "spammethod(20)" sort=no -->
<!--# var no -->
<!--#/in-->
Pavlos