durusmail: quixote-users: Using _q_access? Any place for a _q_traverse?
Using _q_access? Any place for a _q_traverse?
2003-08-22
Re: Using _q_access? Any place for a _q_traverse?
2003-08-22
2003-08-22
Re: Using _q_access? Any place for a _q_traverse?
2003-08-22
2003-08-22
2003-08-23
2003-08-24
2003-08-24
2003-08-24
2003-08-24
2003-08-25
Using _q_access? Any place for a _q_traverse?
VanL
2003-08-22
Hello,

I am trying to set up a simple access control for a quixote site.  I
have the login/logout forms, but I have so far been unsuccessful trying
to enforce the authentication.

I first tried the following:

def _q_lookup(request, component=None):
     session = request.session
     if session.user is None:
         request.redirect('/login')
     else:
         if component is None:
             return frontpage
         if component == 'nextpage':
             return nextpage

_q_index = _q_lookup

But it fails if I return a namespace instead of a string.

I also tried _q_access

def _q_access(request):
     session = request.session
     if session.user is None:
         return login(request)

This works for all accesses to the front page.  However if I try to go
to the url /nextpage (a new namespace) it allows access.

What I really want is a gatekeeper function -- one that I can force all
requests traversing a particular namespace to go through.  This
gatekeeper can do authentication (as above), but it can also initialize
certain connections that need to be initialized differently depending on
the user accessing them.

Is there anything like _q_traverse(request, component) that is meant to
return a namespace (like _q_resolve), but that 1) gives access to the
current request, and 2) does not cache the namespace resolution?

Thanks,

VanL



reply