On Wednesday 27 August 2003 02:26 pm, rpenatez@lattice.com.co wrote:
Hello Zopers! I need to write a global variable into my Zope project but I don't know how to do it. HELP!!!! RicardoP
There's really no such thing as a global variable! In the context of a single executable, we mean "in the scope of the whole executable program in a given instance or invocation of the program". That seems obvious when programming a simple executable program. But for a web application, the situation is more complex. Which scope or lifetime should the variable have? Is it a property of the object/instance in the ZODB? Is it a property of a "session" with a particular user? Is it a property of the entire web application on a given server? Is it a per-server property? Is it a per-page property? Is it a per-user property? Is it a property of the particular release of your product? Or your site? Perhaps it should even apply to all server running the program in the entire world (which would be truly "global"). Where you put the variable will depend on which of these many possibilities you meant. Some of the places I have put variables that are "global" in one of these various ways: * MySQL database field, keyed to the user * Property of a high-level folder * Defined in an imported Config.py file in the product * Class attribute of a particular kind of Zope object * Stored in the REQUEST or in an HTML "POST" web form in a hidden form Cheers, Terry -- Terry Hancock ( hancock at anansispaceworks.com ) Anansi Spaceworks http://www.anansispaceworks.com