Grant Beasley
gbeasley at tsa.ac.za
Tue Apr 23 08:06:07 EST 2002
I've achieved a similar thing by creating a Globals module. This is imported by all modules that require any global variable. I'm also using this module to store a dictionary of users as well as other cached content. It seems to work effectively for me. Anyone aware of any problems with this approach? Thanks Grant Beasley Technikon SA -----Original Message----- From: mod_python-admin at modpython.org [mailto:mod_python-admin at modpython.org]On Behalf Of Marcelo M. Sobral Sent: 23 April 2002 02:34 To: Javier Quinteros Cc: mod_python at modpython.org Subject: Re: [mod_python] Global variable... On Mon, 22 Apr 2002, Javier Quinteros wrote: > What should I do if I want a variable to live for ever? I mean, I don't want > to redefine the variable every time I import a module (where I use it) or > click a link. HI. You must use shared memory for that. The shmmodule can help you (look for it on Vault of Parnassus). I have written a trivial class to save and restore objects in the shared memory. You can download it from: http://www.sj.univali.br/~sobral/persist.tgz It has been used to implement a cache for logins and passwords, used by a PythonAuthenHandler. The cache is a dictionary, which lives in the sahred memory. It has some comments to help you to use it. Best regards. ------------------------ Prof. Marcelo Maia Sobral Administrador de Redes Nucleo de Informatica Univali - Campus São José Fone: (0xx48) 281-1595 ----------------------------- -----BEGIN PGP PUBLIC KEY BLOCK----- Version: GnuPG v1.0.6 (GNU/Linux) Comment: For info see http://www.gnupg.org mQGiBDwiFZQRBACpWV7f+1b1H2Efm9WHM5LnQxQcXEBz/SHff9B909IL5kl5zAL1 F4+mABr4g25wUGKb2SLk6/zb7EPpgI6IrfG7gKqv4PRn8KRkGANSdSouiyqKd8qa JPIwR7i5cCV1hz2p4T7An5307HiJj/BiAXtDtPnD9JKf3gx4upOqbyyyYwCg8gFr AdI1OK++OvBcyCebHM4ojoUEAJedtyxaL/A3rnQ1Ni2DiX60I3mbCx2eWUgm506S RCkwuMzIB2tEMGQg3acqZvTk/7i6ek01Hkk7d8UCZjubKnj8kN23ew5k5/PbFMbF +02tvYy91240MBmTswgW/QTjpU6dRdhtOwOLuuNKUPOII1TtdqQUg+/sWnyfLyrC 5XSGA/wPJAVIEFbvwQUb/XPr9hi+flNjsgEvv6cZDs4b83YwtdXuY4OZH7EyeQ4p +aBlkjNJIdqKB6gw7sv5hdAlX+zKgIukw2jDa63PZl3TiIx1y06p5lDWpqbbhVIG ky1cWRif6vo0p2bPeuwcaNleiZiL1hvR79wLw3EYsMB3tbDAJLRPTWFyY2VsbyBN YWlhIFNvYnJhbCAoQWRtaW5pc3RyYWRvciBkZSByZWRlIC0gVW5pdmFsaS1TSikg PHNvYnJhbEBzai51bml2YWxpLmJyPohdBBMRAgAdBQI8IhWUBQkA7U4ABQsHCgME AxUDAgMWAgECF4AACgkQ6vNSIUi7iuxQPgCgjRxk9vyJVt94CjySkZKcDj7jyB4A niVhSkObCMg4iZMSTvD9HZRKAtu6uQENBDwiFZwQBADZEKBHT1MmO8miFB9/V34V xjzSXn3P3vusbgS/4v7Ydf4Lrcfah8qLx/GEf0Cl7PAL8tSEZkl5+fgzIckKLDA4 E61A31xjxi/MVmySqkPrqzI8AmfT/ukSTgFYEpf/hOmBu7c7JH8BT5evZ3wCFRCH aZf/XnNnOLQrmRqrlaM6CwADBQP8CiTjtSxcbVU5vECsy/pnAjag7EdeLdBzjM17 B0kDDBMYa3VFi6dAkhA1eCe+M7QQBHAzM1xCXLT1ZepteZiqwpb+dSq++0XKLUea uJclWUn8DbwMWGKTdI4weGGr9Bcaq8EZpzzo2uDDbIh3kKGtFntVEFGvg4HorWNM vLOVCwOITAQYEQIADAUCPCIVnAUJAO1OAAAKCRDq81IhSLuK7HNxAJ9UxQo0vu/O NEEsJhrHJoDgpdc2PwCg1c9acqzo9jCig+Y9xWpgJyQpOZQ= =99B8 -----END PGP PUBLIC KEY BLOCK----- _______________________________________________ Mod_python mailing list Mod_python at modpython.org http://www.modpython.org/mailman/listinfo/mod_python
|