[Zope] Help me to TRY

Peter Bengtsson peter@grenna.net
Wed, 28 Mar 2001 18:34:18 +0100


Dear all,

I've got a Zope site that has an interface. People can via the interface
delete real zope objects if they know the password. They don't have to
"/manage", they just call DTML Method that has this in it.

<dtml-call "manage_delObjects('objectid')">

If they previously haven't logged into the Zope realm, they have to do that
naturally if they come across this DTML. Fine.
But If I enclose this in a <dtml-try> tag like this:

<dtml-try>
  <dtml-call "manage_delObjects('objectid')">
<dtml-except>
  bad day!
</dtml-try>

That catches all errors even the not-so-object-error: "the user isn't
authenticated"!
So, what happens is that if I enclose it with a <dtml-try> tag, Zope does
not challange the user to log in.

How can I get both ways?

This is one solution:
<dtml-if "'Manager' in AUTHENTICATED_USER.getRoles()">
  <dtml-call "manage_delObjects('objectid')">
<dtml-else>
  <dtml-try>
    <dtml-call "manage_delObjects('objectid')">
  <dtml-except>
    bad day!
  </dtml-try>
</dtml-if>

But that isn't very good looking and not exactly what I want.

Appreciates it, Peter