[web2py] Re: hide functionality from non authenticated users

2011-11-15 Thread thodoris
There is nothing wrong, i just want to know if this is a clean way
to do what i do above or there is a better way.

Thodoris

On Nov 15, 1:26 pm, Kenneth Lundström kenneth.t.lundst...@gmail.com
wrote:
 Whats wrong in what you just described?

 {{if c != None:}}

 Kenneth







  I want to do the following

  def some_function():
       a = ...
       b = ...
       if auth.is_logged_in():
           c = ...
       else:
           c = None
       return (a=a,b=b,c=c)

  And in the view some_function.html

  {{if c is not None:}}
  do something here
  {{pass}}

  which is the best practice to do it?


Re: [web2py] Re: hide functionality from non authenticated users

2011-11-15 Thread Kenneth Lundström

Looks like a quite clean way.


Kenneth


There is nothing wrong, i just want to know if this is a clean way
to do what i do above or there is a better way.

Thodoris

On Nov 15, 1:26 pm, Kenneth Lundströmkenneth.t.lundst...@gmail.com
wrote:

Whats wrong in what you just described?

{{if c != None:}}

Kenneth








I want to do the following
def some_function():
  a = ...
  b = ...
  if auth.is_logged_in():
  c = ...
  else:
  c = None
  return (a=a,b=b,c=c)
And in the view some_function.html
{{if c is not None:}}
do something here
{{pass}}
which is the best practice to do it?




[web2py] Re: hide functionality from non authenticated users

2011-11-15 Thread Anthony
You can test for a logged in user via:

if auth.user:

auth.user is the record of the currently logged in user, or None if the 
user is not logged in.

Also, do you need to do something with the value of c in the logged in 
case? If not, then just test for a logged in user directly in the view.

{{if auth.user:}}

Anthony

On Tuesday, November 15, 2011 7:37:10 AM UTC-5, thodoris wrote:

 There is nothing wrong, i just want to know if this is a clean way 
 to do what i do above or there is a better way. 

 Thodoris 

 On Nov 15, 1:26 pm, Kenneth Lundström kenneth.t...@gmail.com 
 wrote: 
  Whats wrong in what you just described? 
  
  {{if c != None:}} 
  
  Kenneth 
  
  
  
  
  
  
  
   I want to do the following 
  
   def some_function(): 
a = ... 
b = ... 
if auth.is_logged_in(): 
c = ... 
else: 
c = None 
return (a=a,b=b,c=c) 
  
   And in the view some_function.html 
  
   {{if c is not None:}} 
   do something here 
   {{pass}} 
  
   which is the best practice to do it?



[web2py] Re: hide functionality from non authenticated users

2011-11-15 Thread thodoris
If c is for example a form is it safe to return it but not display it
in the view??

On Nov 15, 2:01 pm, Anthony abasta...@gmail.com wrote:
 You can test for a logged in user via:

     if auth.user:

 auth.user is the record of the currently logged in user, or None if the
 user is not logged in.

 Also, do you need to do something with the value of c in the logged in
 case? If not, then just test for a logged in user directly in the view.

     {{if auth.user:}}

 Anthony







 On Tuesday, November 15, 2011 7:37:10 AM UTC-5, thodoris wrote:

  There is nothing wrong, i just want to know if this is a clean way
  to do what i do above or there is a better way.

  Thodoris

  On Nov 15, 1:26 pm, Kenneth Lundström kenneth.t...@gmail.com
  wrote:
   Whats wrong in what you just described?

   {{if c != None:}}

   Kenneth

I want to do the following

def some_function():
     a = ...
     b = ...
     if auth.is_logged_in():
         c = ...
     else:
         c = None
     return (a=a,b=b,c=c)

And in the view some_function.html

{{if c is not None:}}
do something here
{{pass}}

which is the best practice to do it?


Re: [web2py] Re: hide functionality from non authenticated users

2011-11-15 Thread Kenneth Lundström
I think it is safe but maybe waste of resources so send it to view if 
not needed.



Kenneth


If c is for example a form is it safe to return it but not display it
in the view??

On Nov 15, 2:01 pm, Anthonyabasta...@gmail.com  wrote:

You can test for a logged in user via:

 if auth.user:

auth.user is the record of the currently logged in user, or None if the
user is not logged in.

Also, do you need to do something with the value of c in the logged in
case? If not, then just test for a logged in user directly in the view.

 {{if auth.user:}}

Anthony







On Tuesday, November 15, 2011 7:37:10 AM UTC-5, thodoris wrote:


There is nothing wrong, i just want to know if this is a clean way
to do what i do above or there is a better way.
Thodoris
On Nov 15, 1:26 pm, Kenneth Lundströmkenneth.t...@gmail.com
wrote:

Whats wrong in what you just described?
{{if c != None:}}
Kenneth

I want to do the following
def some_function():
  a = ...
  b = ...
  if auth.is_logged_in():
  c = ...
  else:
  c = None
  return (a=a,b=b,c=c)
And in the view some_function.html
{{if c is not None:}}
do something here
{{pass}}
which is the best practice to do it?