Is there a way to declare a global variable in Zope? And is there a way to declare a variable that is available for an entire session? Any help would be greatly appreciated. Thanks. - Asad
Hi You can add a new property to your zope Root Folder object Dragos ----- Original Message ----- From: "Asad Habib" <ahabib@engin.umich.edu> To: <zope@zope.org> Sent: Tuesday, January 20, 2004 6:13 PM Subject: [Zope] Global Variables
Is there a way to declare a global variable in Zope? And is there a way to declare a variable that is available for an entire session? Any help would be greatly appreciated. Thanks.
- Asad
_______________________________________________ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
From: "Asad Habib" <ahabib@engin.umich.edu>
Is there a way to declare a global variable in Zope? And is there a way to declare a variable that is available for an entire session?
The session_data_manager would be the right place to go for that.
Use property fields on a folder (all routines can access these variables - given the correct security settings). Some useful code bits: 1) create a new property on a folder: <dtml-call "temp_folder.manage_addProperty('newtestpropvar', 'initial contents', 'string')"> you can then access the property field just like a normal REQUEST variable: eg. <dtml-var newtestpropvar> note: this code chunk uses the 'temp_folder' folder which is a folder stored in RAM and any content stored in this folder will disappear if zope is stopped/restarted. If you do not want to lose your content, use a regular folder. 2) check to see if property exists on a given folder: <dtml-call "REQUEST.set('ownerid', 'testpropvar')"> <dtml-if "temp_folder.getProperty(ownerid, 'none') != 'none'"> <dtml-var ownerid> exists<br> <dtml-else> <dtml-var ownerid> does not exist<br> </dtml-if> Jonathan ----- Original Message ----- From: "Asad Habib" <ahabib@engin.umich.edu> To: <zope@zope.org> Sent: January 20, 2004 11:13 AM Subject: [Zope] Global Variables
Is there a way to declare a global variable in Zope? And is there a way to declare a variable that is available for an entire session? Any help would be greatly appreciated. Thanks.
- Asad
_______________________________________________ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
Small Business Services wrote:
<dtml-call "temp_folder.manage_addProperty('newtestpropvar', 'initial contents', 'string')">
<dtml-call "REQUEST.set('ownerid', 'testpropvar')"> <dtml-if "temp_folder.getProperty(ownerid, 'none') != 'none'"> <dtml-var ownerid> exists<br> <dtml-else> <dtml-var ownerid> does not exist<br> </dtml-if>
This really should in in python scripts :-( Chris
"Chris Withers" <chris@simplistix.co.uk> wrote:
<dtml-call "temp_folder.manage_addProperty('newtestpropvar', 'initial contents', 'string')">
<dtml-call "REQUEST.set('ownerid', 'testpropvar')"> <dtml-if "temp_folder.getProperty(ownerid, 'none') != 'none'"> <dtml-var ownerid> exists<br> <dtml-else> <dtml-var ownerid> does not exist<br> </dtml-if>
This really should in in python scripts :-(
Why put this code in python scripts? Is there some performance benefit or other reason? Jonathan
Small Business Services wrote:
Why put this code in python scripts? Is there some performance benefit or other reason?
I think it may run faster, but don't quote me on that. It'll certainly be easier to read, and hence easier to maintain in the long run. cheers, Chris
participants (5)
-
Asad Habib -
Chris Withers -
Dragos Chirila -
Lennart Regebro -
Small Business Services