[Zope] Error Handling

Tino Wildenhain tino@wildenhain.de
Wed, 14 Mar 2001 14:16:30 +0100


Hi Alex,

with zope all you need is a database and database-adapter 
wich supports transactions, since this is already handled
by zpublisher.

The interface defines transaction begin on all databases,
including zodb and every used one in zsql-methods in the 
object. If all is successfully (e.g. no exception has to be
handled by zpublisher) all databases get a transaction end
(to commit) otherwise, if something went wrong it sends
transaction rollback to all of them.

Probably mySQL does not support transactions or your DA does not
for mySQL (recently heard the last release of mySQL supports
transations now, so someone has to rewrite the DA)

With postgresql etc. you can use the mechanism.

See http://www.zope.org/Members/mcdonc/HowTos/transaction

for reference.

HTH
Tino Wildenhain

Alex Verstraeten wrote:
> 
> Hey guys,
> 
> let's say I've got a dtml method which calls 4 other methods:
> 2 of these method inserts data into MySQL
> the other 2 methods creates images using manage_addImage()
> 
> to have a nice consistency I need these 4 actions to perform sucessfully or
> cancel the whole operation.
> 
> is there a better solution than doing this:
> 
> <dtml-try>
>    <dtml-call method1>
> <dtml-except>
>    some html response
> <dtml-else>
>    <dtml-try>
>        <dtml-call method2>
>    <dtml-except>
>       <dtml-call undo_method1>
>    <dtml-else>
>        <dtml-try>
>            <dtml-call method3>
>        <dtml-except>
>            <dtml-call undo_method2>
>            <dtml-call undo_method1>
>        <dtml-else>
>            <dtml-try>
>                 <dtml-call method4>
>             <dtml-except>
>                 <dtml-call undo_method3>
>                 <dtml-call undo_method2>
>                 <dtml-call undo_method1>
>             </dtml-try>
>        </dtml-try>
>    </dtml-try>
> </dtml-try>
> 
> Thanks in advance!
> 
> _______________________________________________
> Zope maillist  -  Zope@zope.org
> http://lists.zope.org/mailman/listinfo/zope
> **   No cross posts or HTML encoding!  **
> (Related lists -
>  http://lists.zope.org/mailman/listinfo/zope-announce
>  http://lists.zope.org/mailman/listinfo/zope-dev )