you are instantiating the variable on class definition, try doing on
function execution instead

On Thu, Apr 16, 2015 at 12:43 PM, Silvio Benvegnù <[email protected]>
wrote:

> I'm using Django Framework 1.7 with its webserver.
>
> I have a custom class where I declare a static variable, a list, where I
> append some values:
>
> class my_class:
>
>     list = []
>
>     def __init__( self, *args, **kwargs ):
>         [...]
>
>     def append_value(self,value):
>         self.list.append( value )
>
> I use a static variable because I call this function different times.
> During a single page load my class works well but I noticed that
> my_class.list never expire.
>
> To reset the list I have to restart the webserver.
>
> I come from PHP and Perl where every time you refresh a page all yor
> variables are cleared if you don't save them in some way.
>
> I use session, sure, but I don't save that list into session, at least not
> voluntarily.
>
> NOTE: I don't know, during script execution, the first or the last time I
> call my_class().
>
> How can I reset the list every time I reload/change page?
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/f7f81ae7-8c33-49e8-8781-86c4c5cd2edb%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/f7f81ae7-8c33-49e8-8781-86c4c5cd2edb%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAFWa6tJEim8p58amRV_wu1qWkGq8cTRiCzpoGp8wQBbZo2-ZYQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to