Pawel J. Maczewski wrote: > Hi, > I'm very new at this list and I've started my experiences > with WebWare not long ago. It looks nice, very nice for me :) > But I have a problem, > I'd like to do some things while initializing the > application server: set the values for a few variables, to be > visible for all other scripts (servlets), open a DB > connection and also have some kind of this-connection-id in a > variable... Could it be done in the __init__.py file (I > think, it's made for it :) Well, but this is my problem: I'd > like to set the DEBUG (f.e.) = 1 (to tell all the servlets to > display additional debug information) and I'd like to set it > once - so what should I do? is there any possibility to set > some values in one file and retrive it in another? > > I'd be veery glad for any help, > tia > Pawel
My recommendation is to put your initialization code into a separate module and just import it wherever you need it. The first time it gets imported, the code in the module will be executed. If you _really_ need that code to run right when the appserver starts up, then you can import the module inside of your context's __init__.py, because that gets imported right when the appserver starts up. In other words: in __init__.py place "import mymodule" which will cause the code in mymodule.py to be executed. This isn't really necessary because the first time a servlet imports mymodule it will be executed anyway. In mymodule.py place your startup code. This will only get run once. In any servlets you can place "import mymodule" to get access to that module. - Geoff ------------------------------------------------------- This SF. Net email is sponsored by: GoToMyPC GoToMyPC is the fast, easy and secure way to access your computer from any Web browser or wireless device. Click here to Try it Free! https://www.gotomypc.com/tr/OSDN/AW/Q4_2003/t/g22lp?Target=mm/g22lp.tmpl _______________________________________________ Webware-discuss mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/webware-discuss
