[Zope] handling exceptions for external methods

David Bear David.Bear at asu.edu
Mon Jul 9 16:21:06 EDT 2007


On Sat, Jul 07, 2007 at 08:11:29AM +0200, Andreas Jung wrote:
> >1 external methods run in the same interpreter as zope
> right
> >2 external methods have access to a larger namespace and therefor more
> >functionality
> 
> they have access to the *full* Python functionality
> >3 external methods inherit the same namespace available to scripts
> >running inside zope
> 
> inherit? Using 'self' as first parameter give you access to the
> current object (for acquisition).
> 
> >
> >4 external methods are not launched as forked or spawned child
> >processes
> 
> right
> 
> >
> >5 external methods do not have access to stdin/stdout
> 
> There is no usecase for accessing stdin from external methods and you might
> to use stdout only for debugging purposes only.
> 
> >
> >6 external methods must return only strings,
> 
> Nonsense. External methods can return anything.
> 

okay, I was thinking strictly in terms of using an external method in
a tal statment. All the examples I've seen in the zope book all have
external methods return html or xml as data that is sent back to the
browser. I never though of having an external method return a standard
python object back to a script and then have the script do something
with the object.

It would be really nice if there were more examples of using external
methods -- my concept of how to use them gets limited by the examples
that I see.

So, if there are more examples or use cases of external methods, I'd
appreciate a pointer to them.

Thanks.

> >but they may be unicode
> >string as long as they are valid xml string data
> 
> Nonsense. There is no contract in Zope telling some method
> to return XML at all.
> 
> >
> >Something that I don't understand is how to handle an exception. For
> >example, if I have an external method that appends data to the end of
> >a file, if there is an IOException how to I capture it and send a
> >message back to zope with something informative?
> 
> You must raise an exception if your failure is supposed to perform
> a ZODB abort operation. Otherwise catch the exception and return some 
> friendly error message back.
> 
> -aj
> 



-- 
David Bear
phone: 	602-496-0424
fax: 	602-496-0955
College of Public Programs/ASU
University Center Rm 622
411 N Central
Phoenix, AZ 85007-0685
 "Beware the IP portfolio, everyone will be suspect of trespassing"


More information about the Zope mailing list