[Zope] external methods
Pedro Vale Lima
eq3pvl@eq.uc.pt
Fri, 26 Mar 1999 12:24:44 +0000
Service Informatique CHSR wrote:
>
> Hello,
>
> I'm confused with external methods. Please help.
>
> I want an external method to access its context (for the
> purpose of acquisition, etc.). So I write:
>
> def myExtMethod(self):
> pass
> Within myExtMethod, I should be able to:
> - write self.REQUEST to access the current REQUEST object (I
> need to be able to modify the current REQUEST object with
> self.REQUEST.set(...))
> - or for example self.myzsqlmethod() to call a zsql method object,
> right???
yes, I guess your are right.
> Let's suppose that myExtMethod is:
>
> def myExtMethod(self):
> l=[]
> for i in self.l:
> l.append(i+1)
> self.REQUEST.set('l', l)
Maybe It's self.l that causes the error. It's hard to understand what
you want, but I feel it should be
for i in l
> Now, how can I call this method from DTML?
>
> <!--#var myExtMethod-->
> <!--#var "myExtMethod()"-->
> <!--#var "myExtMethod(this())"-->
>
> All don't work. I end up in a traceback. "read only class, buffer"
Maybe I can help you with this. The traceback you get is probably the
standard error raise in ExternalMethods. To debug external methods I use
try/except/raise code blocks and when I get an exception I return it to
the screen. Something like this
def mymethod(self):
try:
mycode
except:
import sys
return sys.exc_type, sys.exc_value
return something
pedro
--
Pedro Vale Lima
eq3pvl@eq.uc.pt