Hello fellow Zope developers I extended the new 'try' tag to include support for an optional 'else' block, and whipped in support for 'try..finally' as well. The try tag now has this form: try [[except]* [else] | [finally]] /try. I also added more rigorous checks on it's syntax, like allowing only one default exception handler. Attached you'll find a patch against the latest CVS, but it will work on Zope 2.0a4 and higher. The file to patch is lib/python/DocumentTemplate/DT_Try.py. Let me know what you'll think. I'll post this patch to the Collector as well. Here is it's documentation string: Zope DTML Exception handling usage: <!--#try--> <!--#except SomeError AnotherError--> <!--#except YetAnotherError--> <!--#except--> <!--#else--> <!--#/try--> or: <!--#try--> <!--#finally--> <!--#/try--> The DTML try tag functions quite like Python's try command. The contents of the try tag are rendered. If an exception is raised, then control switches to the except blocks. The first except block to match the type of the error raised is rendered. If an except block has no name then it matches all raised errors. The try tag understands class-based exceptions, as well as string-based exceptions. Note: the 'raise' tag raises string-based exceptions. Inside the except blocks information about the error is available via three variables. 'error_type' -- This variable is the name of the exception caught. 'error_value' -- This is the caught exception's value. 'error_tb' -- This is a traceback for the caught exception. The optional else block is rendered when no exception occurs in the try block. Exceptions in the else block are not handled by the preceding except blocks. The try..finally form specifies a `cleanup` block, to be rendered even when an exception occurs. Note that any rendered result is discarded if an exception occurs in either the try or finally blocks. The finally block is only of any use if you need to clean up something that will not be cleaned up by the transaction abort code. The finally block will always be called, wether there was an exception in the try block or not, or wether or not you used a return tag in the try block. Note that any output of the finally block is discarded if you use a return tag in the try block. If an exception occurs in the try block, and an exception occurs in the finally block, or you use the return tag in that block, any information about that first exception is lost. No information about the first exception is available in the finally block. Also, if you use a return tag in the try block, and an exception occurs in the finally block or you use a return tag there as well, the result returned in the try block will be lost. Original version by Jordan B. Baker. Try..finally and try..else implementation by Martijn Pieters. -- Martijn Pieters, Web Developer | Antraciet http://www.antraciet.nl | Tel: +31-35-7502100 Fax: +31-35-7502111 | mailto:mj@antraciet.nl http://www.antraciet.nl/~mj | PGP: http://wwwkeys.nl.pgp.net:11371/pks/lookup?op=get&search=0xA8A32149 ------------------------------------------