advice about `correct' use of decorator

Lawrence D'Oliveiro ldo at geek-central.gen.new_zealand
Sat Sep 1 03:49:17 EDT 2007


In message <mailman.2074.1187294411.22759.python-list at python.org>, Gerardo
Herzig wrote:

> @is_logued_in
> def change_pass():
>     bla
>     bla
> 
> And so on for all the other functions who needs that the user is still
> loged in.

My suspicion is that most of the methods in your session object (with the
obvious exception of the login method) will require the user to be logged
in, right?

So the trouble with an extra decorator like this, is that you have to
remember to put it on nearly _all_ your methods.

Wouldn't it be simpler and safer to default the other way? Have some way of
saying "doesn't require user to be logged in", and require a valid
logged-in session on all methods where this is not specified?



More information about the Python-list mailing list