[Zope] xmlrpc error handling

2007-04-11 Thread Kevin

In order to avoid zodb implosion, is it sufficient to raise an xmlrpclib
Fault object from a method where some validation was not successful?
Will zope abort transactions and avoid an other avoidable bad things
from happening?  Do I have to use fault or can I raise just any error an
ZPublisher.xmlrpc will marshall it
into fault/fault?

from xmlrpclib import Fault
SomeClass(SimpleItem):
  ...
  def myMethod(self,stuff=[]):
if type(stuff) != list:
   f=Fault
   f(27,stuff must be a list)
   raise f
else:
 print stuff

Thanks,
Kevin


___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
http://mail.zope.org/mailman/listinfo/zope-announce

http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] xmlrpc error handling

2007-04-11 Thread Paul Winkler
On Wed, Apr 11, 2007 at 01:38:21PM -0400, Kevin wrote:
 In order to avoid zodb implosion, is it sufficient to raise an xmlrpclib
 Fault object from a method where some validation was not successful?

yes.

 Will zope abort transactions

yes.

 and avoid an other avoidable bad things
 from happening?

as long as your application is designed well with regard to
transaction boundaries, you'll be fine.  Inconsistencies could arise
if your app does something weird like manually commit a transaction
and start a new one before the exception is raised...

 Do I have to use fault or can I raise just any error an
 ZPublisher.xmlrpc will marshall it
 into fault/fault?

The latter. Try it and see :)

AFAICT any uncaught exception will be published as an xmlrpc fault.
But then I think you don't have control of the fault code, if you care
about that.


-- 

Paul Winkler
http://www.slinkp.com
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )