All that's fine by me, and allowing an error handler to have side
effects explicitly is probably a good idea...  will anybody volunteer to
do this for 2.7?

- C


On Mon, 2003-02-03 at 03:44, Steve Alexander wrote:
> By conincidence I'm implementing something similar for error handling in 
> Zope 3 right now.
> 
> Here's the kind of thing I'm doing in zope 3, using the same notation 
> Dieter used. First, the simple case where the error handler will 
> definitely not need to alter any state:
> 
>    ## request starts
>    transaction.begin()
>    try:
>        object= REQUEST.traverse(...)
>        result = mapply(object,...)
>        transaction.commit()
>    except:
>        try:
>            try:
>                 result = handle_error()
>            except:
>                 result = default_handle_error()
>                 # Zope's default error handling
>                 # it must not have side effects
>        finally:
>            transaction.abort()
>    request.response.setBody(result)
>    ## request ends
> 
> If there's an exception handler that has side-effects, it must 
> explicitly say so, and we get this:
> 
>    ## request starts
>    transaction.begin()
>    try:
>        object= REQUEST.traverse(...)
>        result = mapply(object,...)
>        transaction.commit()
>    except:
>        try:
>            try:
>                 # this call returns a special
>                 # 'I have side-effects' token.
>                 result = handle_error()
>            except:
>                 result = default_handle_error()
>                 # Zope's default error handling
>                 # it should not have side effects
>        finally:
>            transaction.abort()
> 
>    if result is I_HAVE_SIDE_EFFECTS:
>        transaction.begin()
>        transaction.note('%s (application error handling)'
>                         % '/'.join(object.getPhysicalPath))
>        try:
>            result = handle_error_with_sideeffects()
>            transaction.commit()
>        except:
>            try:
>                result = default_handle_error()
>                # Zope's default error handling
>                # it should not have side effects
>            finally:
>                transaction.abort()
>    else:
>        request.response.setBody(result)
>    ## request ends



_______________________________________________
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://mail.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope )

Reply via email to