On Nov 3, 2:36 pm, jgfoot <[EMAIL PROTECTED]> wrote:
> I've put together a small and simple decorator that lets web.py code
> require HTTP "basic" authentication before running a function or
> method.  (HTTP authentication is when the browser pops up that
> "username/password" dialog box).
[...]
> Please check it out athttp://www.goldfoot.com/basicauth.py(a
> temporary location only) and let me know what you think.  Because this
> uses decorators, it needs Python 2.4 or later.

Nice effort, however...

Decorators only take one argument; instead of:
  def decorator(func, *args, **keywords):
you should just say:
  def decorator(func):

Also, I'd think strongly about making this a class that has, as a
default, a deny-all behavior.  Users of the class would then override
that method to define various access policies.

Finally, in your sample usage, don't call your decorator 'auth'.  When
I saw '@auth' decorating your 'def GET', I initially thought you were
calling the auth defined below.  The example in the doc-string (using
'myauth') works much better.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"web.py" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/webpy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to