[Zope] Re: Transactions in Zope?

Bruce Eckel Bruce@EckelObjects.com
Sat, 24 Nov 2001 16:45:48 -0800


I see the problem -- I was catching my own exceptions, so the
normal Zope mechanism wasn't being used.

But this brings up a bit of a quandary:

        try:
            self.MailHost.send("This is a test", 
              'Bruce@EckelObjects.com', form_data['email'], 
              "%s\n\n" % form_data['seminar-id'])
        except smtplib.SMTPSenderRefused:
            return "Invalid email address: please press your
browser's 'back' key and correct it"

I'd like to both
* catch the exception and produce an error message for the user
* use the rollback mechanism in Zope

Can I have my cake and eat it too?

*********** REPLY SEPARATOR  ***********

On 11/24/01 at 6:32 PM Chris McDonough wrote:

>All you need to do is raise an exception.  Zope rolls back changes
to
>the point at which the transaction was started (the beginning of
the
>request).
>
>----- Original Message -----
>From: "Bruce Eckel" <Bruce@EckelObjects.com>
>To: <zope@zope.org>
>Cc: <ecofsky@theUNIXman.com>; <chrism@digicool.com>
>Sent: Saturday, November 24, 2001 10:59 AM
>Subject: Transactions in Zope?
>
>
>> I am creating an external method that makes a folder, creates a
>> dtml method in that folder, and then sends an email message. If
any
>> of these operations fail, I'd like to "roll back" to the state
>> before the method was called. I think I heard that zope has
>> transactions of some kind, and I'm making mods to the ZODB in my
>> external method, so is there a magic piece of code that would
roll
>> everything back?
>>
>> Thanks!
>>
>>