[mod_python] global persistence

Jonathan Gardner jgardner at jonathangardner.net
Tue Jun 24 17:07:29 EST 2003


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Tuesday 24 June 2003 01:11, 1 1 wrote:
> Greetings to all,
>
> I'm using Apache 1.3.24 + mod_py 2.7.8.
>
> The idea is to make mod_py have global variables that
> will be accessible from any request untill apache restarts.
>

Start over. Rethink what you are trying to do.

Let's examine things fundamentally. How does apache work? It listens on port 
80. It spawns a bunch of children. When it gets an incoming connection, it 
passes the connection off to one of the children.

These children are seperate processes. There is no way for them to 
communicate with each other outside of pipes and shared memory. (Well, 
there are other ways, but they aren't as useful as you would hope).

So far, no one has figured out how to use shared memory and python. However, 
everyone and their sister knows how to use pipes. It's called "sockets" and 
you can use TCP over IP or one of a million other protocols.

So, these processes have to communicate with each other. How are they going 
to find each other, let alone let each other know when something changes 
and how it changes? Why, we need a central location for all of them to call 
in to. Let's call it a server.

And what will this server do? It will hold data. Maybe we should call it a 
"database". So, any process running out in the wild can connect to this 
database, grab data, change data, and everyone will work together.

That's your "global variables" accessible anywhere. That's the current best 
way to do it. You'll find a terrifying amount of research done on 
everything you can possibly imagine doing with a database.

I suggest PostgreSQL as a database. Others will suggest MySQL, SQL Server, 
Oracle, or Sybase.

So go start learning about databases, and how best to use them! ;-)

- -- 
Jonathan Gardner
jgardner at jonathangardner.net
(was jgardn at alumni.washington.edu)
Live Free, Use Linux!
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)

iD8DBQE++OfBWgwF3QvpWNwRAsq8AKC0R3Xp1xmJDWu6cmUD2KDTNo9EbgCgiODn
yVGztiDpf5ZizHramVNSUw8=
=RvEH
-----END PGP SIGNATURE-----




More information about the Mod_python mailing list