To use in a session, simply assign as a session member:
if not session.temp_list:
    session.temp_list = greylist

Then, refer to session.temp_list everywhere you should do to temp_list.

I think an example from the book will help you:
http://web2py.com/books/default/chapter/29/03#Let's-count




On Wed, May 8, 2013 at 8:11 PM, Nam Soo In <[email protected]> wrote:
> Hi, I wonder how to use global variable
> Let me show my code
>
> def emps_greylist():
>     import urllib2
>     from lepl.apps.rfc3696 import HttpUrl
>     from urlparse import urlparse
>
>
>     diff_list=[]
>     temp_list=[]
>     top_level_url = "https://xxx/greylist.txt";
>
>     greylist = urllib2.urlopen(top_level_url)
>
>
>     if not temp_list:
>         temp_list=greylist
>
>     else :
>         diff_list = [item for item in greylist if not item in temp_list]
>         greylist=diff_list
>
>
> I would like to have temp_list as global variable
> I tried to look up some solutions.
> Session and cache are solutions.
> Can somebody tell me how to use them.
>
> --
>
> ---
> You received this message because you are subscribed to the Google Groups
> "web2py-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to