durusmail: quixote-users: Authentication/permissions
Authentication/permissions
2004-11-08
2004-11-09
2004-11-10
2004-11-10
Authentication/permissions
Mike Orr
2004-11-09
On Tue, Nov 09, 2004 at 12:22:06PM -0500, Neil Schemenauer wrote:
> On Mon, Nov 08, 2004 at 01:22:27PM -0800, Mike Orr wrote:
> > I could put a _q_access() at the top level of the site, but since it
> > can't return an alternate page, that doesn't help.
>
> What we do have _q_access() raise a NotLoggedInError exception which
> is a subclass of AccessError.  Our _q_exception_handler formats it
> so that a login form is displayed.

I ended up adding two lines to Publish.process_request() in a subclass:

    except AccessDocument, exc:
        output = str(exc)

I looked at propagating _q_access's return value if it's not none, but
the call is buried in a long function (_get_component).  Using an
exception provides a quick way jump back through nested calls.

I hadn't thought of using _q_exception_handler because I thought that
was just for reformatting a traceback or printing error messages.  In
my case, I'd have to pass the entire HTML page as the exception
argument, otherwise the handler would have to go through the same
decision steps _q_access is already doing.

--
-Mike Orr (aka. Sluggo), mso@oz.net  (iron@sense-sea-MegaSub-1-465.oz.net)
   http://sluggo.kicks-ass.org/                  Cxu vi parolas Esperante?

reply