[Zope] using getProperty and catching Unauthorized

John K. Hohm jhohm@acm.org
Thu, 24 Oct 2002 21:09:07 -0500


Using Zope 2.6.0, I have a script that returns a list of items to be shown in a
navigation menu.  I want to show only items where both a menu_order property
exists and the user has permission to view the object (which will not always be
controlled by 'View').  I can't use foo.getProperty('menu_order', None) because
it will raise Unauthorized for objects the user has no permissions on.  I can't
use getattr(foo, 'menu_order', None) because foo will acquire menu_order, and I
can't pass foo.aq_base or Acquisition.aq_base(foo) to getattr because aq_base
will raise Unauthorized.  If I could catch Unauthorized without also catching
more serious errors, I could use getProperty, but I don't know how to do that.