[Zope] handling exceptions for external methods

Jonathan dev101 at magma.ca
Fri Jul 6 18:49:11 EDT 2007


----- Original Message ----- 
From: "David Bear" <David.Bear at asu.edu>
To: "zope" <Zope at zope.org>
Sent: Friday, July 06, 2007 5:55 PM
Subject: [Zope] handling exceptions for external methods


> I've begun using external methods and am trying to better understand the
> context they run and and how to handle exceptions. I have concluded
> the following (and I don't recall reading some of these in any 
> documentation)
> (please correct me if I'm wrong)
>
> 3 external methods inherit the same namespace available to scripts
> running inside zope

when you define your external method routine:   def xxx(self, ....)
you gain access to zope namespace via self  (eg. self.REQUEST)


> 6 external methods must return only strings, but they may be unicode
> string as long as they are valid xml string data

No.  External methods can return any python type you like (lists, tuples, 
dictionaries, etc).


> 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?

Look up  try/except in a python lib doc.


hth

Jonathan 



More information about the Zope mailing list