[Zope] "Bubbling up" to parent error message?

Joel Burton jburton@scw.org
Tue, 27 Feb 2001 17:42:39 -0500


We have a folder called /home in the root of our site, for our users' 
home directories. If you browse to /home/joel, there's my site. If 
you browse to /home/joel/foo, and I have no resource foo, you 
should get the standard error message. (Which, without any work, 
you do! :-) )

However, if you browse to /home/fooperson, I'd rather you got a 
message that said "Sorry, no user" and listed our users, than having 
you get the standard error message.

So far, I have the following code:


<dtml-comment>

  Handle errors.

  If they're looking for a user that doesn't exist, eg

    /home/foo

  show a "No Such user" message.

  If they're looking in an existing directory, but there's no
  such a document, or, for all other Zope errors,
  do the usual thing.

</dtml-comment>

<dtml-if "error_type=='NotFound' and URLPATH2==''">

  <dtml-var standard_html_header>
    No Such User!
  <dtml-var standard_html_footer>

<dtml-else>
    <dtml-var "PARENTS[2].standard_error_message()">
</dtml-if>


The URLPATH2='' checks that you are looking in /home/xxx. If you're 
looking for /home/joel/xxx, URLPATH2 != '', and you get the else 
clause.

The PARENTS[2] bit is trying to say "show the 
standard_error_message that's up the acquisition chain from this 
one", but failing miserably.

PARENTS[2].standard_error_message w/o () gives me the *source* 
of the error message, w/ () doesn't work, and gives me the hard-
coded-in-sourcecode error message, not the one in my root 
directory.

Any ideas?

Thanks!
--
Joel Burton, Director of Information Systems -*- jburton@scw.org
Support Center of Washington (www.scw.org)