Graham Dumpleton
grahamd at dscpl.com.au
Sat Jun 4 00:37:20 EDT 2005
On 04/06/2005, at 6:09 AM, Al Pacifico wrote: > > Apologies in advance because I come from an Apache 1.3 / mod_perl > background > and am rusty at that to boot. > > I'm wondering how to use PythonAuthenHandler to set my client's > directory > viewing permissions. I'm authenticating against an openLDAP server and > the > basic authentication works. If I understand you correctly, since you already have the authentication bit working, you just want the user authorisation bit. Ie., control what they can access. If this is the case, you should be able to access "req.uri", ie., the resource which the request is against, and in conjunction with the user credentials you already have access to, work out if they should be allowed access. You should be able to do this within you authenhandler and would not need a separate authzhandler. Have I misunderstood? Obviously I can't say how you determine if a URL is accessible to a specific user, as that is going to depend on your requirements. > On a side note, will a 'finally:' clause be executed even if the > 'except:' > clause contains 'return' ? Or should I have result = apache.<whatever> > and > place return result in the finally clause ? From memory, you can't have a "finally" clause at the same level as "except". Ie., if you can't have: try: ... except: ... finally: Thus, if you want a finally clause, you must do: try: try: ... except: ... finally: ... As example, if you have: def func(): try: try: raise 1 except: print "except" return "except" finally: print "finally" #return "finally" print func() the result printed out from "func()" will be "except". If you however uncomment the return from the "finally", the result printed out will be "finally". Thus, as long as the "finally" doesn't have an explicit return, the return from the "except" will be the result of the function in the case that the exception is raised. Someone please correct me if I am wrong. Graham
|