Re: advice about `correct' use of decorator

2007-09-03 Thread Gabriel Genellina
En Wed, 29 Aug 2007 07:32:21 -0300, BJörn Lindqvist [EMAIL PROTECTED] escribi�: On 8/24/07, Gabriel Genellina [EMAIL PROTECTED] wrote: En Thu, 23 Aug 2007 09:20:21 -0300, BJörn Lindqvist [EMAIL PROTECTED] escribi�: def check_user_logged_in(func): def f(*args, **kwargs): if

Re: advice about `correct' use of decorator

2007-09-03 Thread Ricardo Aráoz
Gabriel Genellina wrote: En Wed, 29 Aug 2007 07:32:21 -0300, BJörn Lindqvist [EMAIL PROTECTED] escribi�: On 8/24/07, Gabriel Genellina [EMAIL PROTECTED] wrote: En Thu, 23 Aug 2007 09:20:21 -0300, BJörn Lindqvist [EMAIL PROTECTED] escribi�: def check_user_logged_in(func): def

Re: advice about `correct' use of decorator

2007-09-03 Thread Gregor Horvath
Gerardo Herzig schrieb: @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. where obviosly the is_logued_in() function will determine if the dude is still loged in, and THEN execute change_pass(). If the

Re: advice about `correct' use of decorator

2007-09-01 Thread Lawrence D'Oliveiro
In message [EMAIL PROTECTED], 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

Re: advice about `correct' use of decorator

2007-08-29 Thread BJörn Lindqvist
On 8/24/07, Gabriel Genellina [EMAIL PROTECTED] wrote: En Thu, 23 Aug 2007 09:20:21 -0300, BJörn Lindqvist [EMAIL PROTECTED] escribi�: def check_user_logged_in(func): def f(*args, **kwargs): if global_state.the_user.is_logged_in: return func(*args, **kwargs)

Re: advice about `correct' use of decorator

2007-08-23 Thread BJörn Lindqvist
On 8/22/07, Gabriel Genellina [EMAIL PROTECTED] wrote: On 22 ago, 10:00, BJörn Lindqvist [EMAIL PROTECTED] wrote: As I said, you can accomplish the exact same thing by calling a function from within the function that requires the user to be logged in. def change_pass():

Re: advice about `correct' use of decorator

2007-08-23 Thread Gerardo Herzig
BJörn Lindqvist wrote: On 8/22/07, Gabriel Genellina [EMAIL PROTECTED] wrote: On 22 ago, 10:00, BJörn Lindqvist [EMAIL PROTECTED] wrote: As I said, you can accomplish the exact same thing by calling a function from within the function that requires the user to be logged in. def

Re: advice about `correct' use of decorator

2007-08-22 Thread BJörn Lindqvist
On 8/17/07, Gerardo Herzig [EMAIL PROTECTED] wrote: BJörn Lindqvist wrote: def is_logued_in(): if not user.is_logged_in(): raise NotLoggedInError It costs you one more line, but reduces complexity. And if you are worried about that extra line you can put it in a function. As

Re: advice about `correct' use of decorator

2007-08-22 Thread Gabriel Genellina
On 22 ago, 10:00, BJörn Lindqvist [EMAIL PROTECTED] wrote: On 8/17/07, Gerardo Herzig [EMAIL PROTECTED] wrote: BJörn Lindqvist wrote: def is_logued_in(): if not user.is_logged_in(): raise NotLoggedInError It costs you one more line, but reduces complexity. And if you are

Re: advice about `correct' use of decorator

2007-08-22 Thread Bruno Desthuilliers
Gerardo Herzig a écrit : Steven Bethard wrote: Gerardo Herzig wrote: Hi all. I guess i have a conceptual question: Im planing using a quite simple decorator to be used as a conditional for the execution of the function. (snip) Something in my mind tells me that this is not the

Re: advice about `correct' use of decorator

2007-08-17 Thread Laszlo Nagy
Are you developing a website or a GUI program? It will be used in a web development. It is an important point? Yes, I think. Unless you use AJAX. :-) Most web sites work this way: user clicks - request to server - process on server - response I would rather enclose the whole handler in

Re: advice about `correct' use of decorator

2007-08-17 Thread BJörn Lindqvist
On 8/16/07, Gerardo Herzig [EMAIL PROTECTED] 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. where obviosly the is_logued_in() function will determine if the dude is still loged in, and THEN execute

Re: advice about `correct' use of decorator

2007-08-17 Thread Gerardo Herzig
Laszlo Nagy wrote: Are you developing a website or a GUI program? It will be used in a web development. It is an important point? Yes, I think. Unless you use AJAX. :-) Most web sites work this way: user clicks - request to server - process on server - response I would rather enclose

Re: advice about `correct' use of decorator

2007-08-17 Thread Gerardo Herzig
BJörn Lindqvist wrote: On 8/16/07, Gerardo Herzig [EMAIL PROTECTED] 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. where obviosly the is_logued_in() function will determine if the dude is still loged

Re: advice about `correct' use of decorator

2007-08-17 Thread Steve Holden
Gerardo Herzig wrote: [...] As far as i know (by the way, AFAK is the shortcut? [...] That's AFAIK, AFAIK :-) regards Steve -- Steve Holden+1 571 484 6266 +1 800 494 3119 Holden Web LLC/Ltd http://www.holdenweb.com Skype: holdenweb http://del.icio.us/steve.holden

advice about `correct' use of decorator

2007-08-16 Thread Gerardo Herzig
Hi all. I guess i have a conceptual question: Im planing using a quite simple decorator to be used as a conditional for the execution of the function. I mean something like that: @is_logued_in def change_pass(): bla bla And so on for all the other functions who needs that the user is

Re: advice about `correct' use of decorator

2007-08-16 Thread Laszlo Nagy
Gerardo Herzig wrote: Hi all. I guess i have a conceptual question: Im planing using a quite simple decorator to be used as a conditional for the execution of the function. I mean something like that: @is_logued_in def change_pass(): bla bla And so on for all the other functions

Re: advice about `correct' use of decorator

2007-08-16 Thread Gerardo Herzig
Gerardo Herzig wrote: Hi all. I guess i have a conceptual question: Im planing using a quite simple decorator to be used as a conditional for the execution of the function. I mean something like that: @is_logued_in def change_pass(): bla bla And so on for all the other

Re: advice about `correct' use of decorator

2007-08-16 Thread Steven Bethard
Gerardo Herzig wrote: Hi all. I guess i have a conceptual question: Im planing using a quite simple decorator to be used as a conditional for the execution of the function. I mean something like that: @is_logued_in def change_pass(): bla bla And so on for all the other functions

Re: advice about `correct' use of decorator

2007-08-16 Thread Gerardo Herzig
Steven Bethard wrote: Gerardo Herzig wrote: Hi all. I guess i have a conceptual question: Im planing using a quite simple decorator to be used as a conditional for the execution of the function. I mean something like that: @is_logued_in def change_pass(): bla bla And so on for all