[Zope] Global Variable Definition

McDonnell, Larry lmcdonnell@protonenergy.com
Thu, 27 Jun 2002 15:05:19 -0400


Thank you Casey, this information has eluded me through my readings. Thanks
again, this is a big help in understanding how Zope works.

-----Original Message-----
From: Casey Duncan [mailto:casey@zope.com]
Sent: Thursday, June 27, 2002 2:59 PM
To: McDonnell, Larry
Cc: 'Zope@Zope. Org' (E-mail)
Subject: Re: [Zope] Global Variable Definition


There are three main types of "Global" variables in Zope:

  - REQUEST variables

  - Session Variables
 
  - Persistent Variables (aka Properties)

Request variables are globals that live only for the life of the
request. You set them using REQUEST.set('foo', value) and get them using
REQUEST['foo'].

Session variables live for the life of a user's web session. They are
accessible only by that user. To set these you use
REQUEST.SESSION.set('foo', value) and to get them use
REQUEST.SESSION['foo'].

Properties live indefinitely and are saved in the ZODB as metadata of
specific objects (such as folders or documents). To make it "Global" to
all of Zope, you would set them on the Root Folder. Properties are
accessible to all users of Zope. To set/get these you use:
object.setProperty('foo', value, type) and object.getProperty('foo').

Note that setting properties is more expensive then session variables,
and session variables are more expensive to set then request variables.

hth,

-Casey

On Thu, 2002-06-27 at 14:28, McDonnell, Larry wrote:
> 
> Hi,
> 
> What are the Zope rules in which a variables are classifed as a global
> variables? Can I define a varaible to be placed in the global stack? If so
> how? Or is there a better way track variables through the site. Also is
> there a command that will list the namespace? Thanks.
> 
> 
> Larry McDonnell
> 
> Proton Energy Systems
> 50 Inwood Rd.
> Rocky Hill, CT 06067
> (860) 571-6533 ext. 531
> Email:lmcdonnell@protonenergy.com
> www.protonenergy.com
> 
> 
> 
> _______________________________________________
> Zope maillist  -  Zope@zope.org
> http://lists.zope.org/mailman/listinfo/zope
> **   No cross posts or HTML encoding!  **
> (Related lists - 
>  http://lists.zope.org/mailman/listinfo/zope-announce
>  http://lists.zope.org/mailman/listinfo/zope-dev )