[Zope] Exceptions, exceptions...

Ramiro Brito Willmersdorf rbw@demec.ufpe.br
Tue, 26 Sep 2000 21:24:56 -0300


Hi, 

Yesterday I posted the message below, and I'm happy to inform all
that the problem was basically just my advanced braindeath.

I decided to triple check everything today, after a good night of sleep, (and a
so so day of real work) and found out that the variable I could swear was being
used inside the external method wasn't really.  It would be referenced only
after the location where the exception was triggered, so it being undefined
didn't trigger an error as I had naïvely expected.  I just had forgotten to set
it explicitly in the page that called the external method.

The good news is that the exception machinery then seems to work exactly as one
would expect, and quite wonderfully at that.

Many thanks to all those that developed such a great system,

Ramiro.

> Hi,
> 
> I have a DTML document with the following structure:
> 
> <dtml-var standard_html_header>
> <dtml-try>
>    <dtml-call "my_external_method(REQUEST)">
>       <p> Report that everything was ok and wait for ack.
>       <form method=POST action=index_html> <input type=submit value="OK"> </form>       
> <dtml-except MyException>
>       <p class="warning"> Warn about problem found by external method.
>       <form method=POST action="treatError"> <input type=submit value="OK"> </form>
> </dtml-try>
> <dtml-var standard_html_footer>
> 
> and it works wonderfully, to be honest I thought it was quite uncanny to define
> and raise an exception inside the python module, and having it caught by the
> DTML document.
> 
> Now, to improve the treatment of errors I need to refer, inside the
> <dtml-except> block, to some variables that were defined in the REQUEST
> variable (I'm pretty confident of this  because I used them inside the external
> method), but it seems that the original REQUEST variable is no longer set
> inside the <dtml-except> block.  Is this correct? What actually happens (in
> simple terms, please :) when an exception is thrown?
> 
> I also tried the very few other tricks I know with DTML (<dtml-with
> "_.namespace..."> outside the <dtml-try> block, plus some other voodoo) but
> couldn't get it to work, either.
> 
> Should I return these values as error values with the exception?  I can do it
> if this is the only option, but I'm already using the return value for
> information related to external method things, and I'd rather not mix the two
> ``domains'', so to speak.
> 
> Many thanks for any tips,
 
-- 
Ramiro Brito Willmersdorf            rbw@demec.ufpe.br  
GPG key: http://www.demec.ufpe.br/~rbw/GPG/gpg_key.txt