[Zope-dev] Re: Post-authentication hook

Evan Simpson evan@4-am.com
Tue, 10 Jun 2003 13:41:30 -0500


Dieter Maurer wrote:
> We had discussed the post-authentication hook in connection
> with role based skin selection but we never had it implemented.

I have, and it even fits here in the margin.  Shall I pop it into the 
Collector?

242a243
 >         self._post_traverse = post_traverse = []
363a365
 >         del self._post_traverse
434a437,439
 >         if post_traverse:
 >             exec_callables(post_traverse)
 >
444a450,453
 >     def post_traverse(self, f, args):
 >         """Set a callable object and argument tuple
 >            to be combined if traversal succeeds"""
 >         self._post_traverse.append((f, tuple(args)))
445a455,470
 > def exec_callables(callables):
 >     for (f, args) in callables:
 >         try:
 >             f(*args)
 >         except (ArithmeticError, AttributeError, FloatingPointError,
 >                 IOError, ImportError, IndexError, KeyError,
 >                 OSError, OverflowError, TypeError, ValueError,
 >                 ZeroDivisionError):
 >             # Only catch exceptions likely to be logic errors.
 >             # We shouldn't catch Redirects, Unauthorizeds, etc. since
 >             # the programmer may want to raise them deliberately.
 >             from zLOG import LOG, ERROR
 >             import sys
 >             LOG('PostTraverse', ERROR,
 >                 'Error while invoking hook: "%s"' % `f`,
 >                 error=sys.exc_info())