On Aug 14, 10:13 pm, Jani Tiainen <[email protected]> wrote:
> Steve Patrick kirjoitti:
>
> > Hi everybody,
> > I´m new in Django and maybe my problem is a bit stupid...I would like
> > to use a global variable (for all the application) to store some info
>
> No you don't want to. And even it's possible in theory, you shouldn't
> even consider that option.
>
> > that I get in my firts page. I know I can send variables using
> > render_to_response, but is there any other easy way??is it possible to
> > define a global variable, initialize it in my first page and just use
> > it??
>
> Store value in session?
>
> First at all, your variable would only live time of request (meaning
> from the moment URL is parsed and reponse is sent to your browser). What
>   happens to your "global" after that? It wouldn't exist on next request.

That is not true.

Global variables at Python module scope will last for the life time of
the process.

That said, you must still be careful about using them because server
may be multiprocess and/or multithreaded, both of which causes issues
with doing it that way.

Have a read of:

  http://code.google.com/p/modwsgi/wiki/ProcessesAndThreading

as it says a bit about that.

Graham
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to