Transient Objects
TransientObjectContainers hold transient objects, most often, session data.
You will rarely have to script a transient object
container. You'll almost always deal with a TransientObject
itself which you'll usually get as REQUEST.SESSION
.
Returns the current before destruction
function, or None.
View management screens
Returns the current after add
function, or None.
View management screens
Return value associated with key k. If value associated with k does not exist, return default.
Access Transient Objects
If an object already exists in the container with key "k", it is returned.
Otherwiser, create a new subobject of the type supported by this container with key "k" and return it.
"k" must be a string, else a TypeError is raised.
If the container is full
, a MaxTransientObjectsExceeded exception
be raised.
Create Transient Objects
Returns a meaningful unique id for the object.
Cause the after add
function to be f
.
If f
is not callable and is a string, treat it as a Zope path to
a callable function.
after add
functions need accept a single argument: item
, which
is the item being added to the container.
Manage Transient Object Container
Return true if container has value associated with key k, else return false.
Access Transient Objects
Return the number of minutes allowed for subobject inactivity before expiration.
View management screens
Set the number of minutes of inactivity allowable for subobjects
before they expire (timeout_mins) as well as the timeout resolution
in seconds (period). timeout_mins
* 60 must be evenly divisible
by the period. Period must be less than timeout_mins
* 60.
Manage Transient Object Container
Creates a new subobject of the type supported by this container with key "k" and returns it.
If an object already exists in the container with key "k", a KeyError is raised.
"k" must be a string, else a TypeError is raised.
If the container is full
, a MaxTransientObjectsExceeded will
be raised.
Create Transient Objects
Return the timeout resolution
in seconds.
View management screens
Cause the before destruction
function to be f
.
If f
is not callable and is a string, treat it as a Zope path to
a callable function.
before destruction
functions need accept a single argument: item
,
which is the item being destroyed.
Manage Transient Object Container
A transient object is a temporary object contained in a transient object container.
Most of the time you'll simply treat a transient object as a dictionary. You can use Python sub-item notation:
SESSION['foo']=1 foo=SESSION['foo'] del SESSION['foo']
When using a transient object from Python-based Scripts or DTML
you can use the get
, set
, and delete
methods instead.
Methods of transient objects are not protected by security assertions.
It's necessary to reassign mutuable sub-items when you change them. For example:
l=SESSION['myList'] l.append('spam') SESSION['myList']=l
This is necessary in order to save your changes. Note that this caveat is true even for mutable subitems which inherit from the Persistence.Persistent class.
Returns the key under which the object is "filed" in its container. getContainerKey will often return a differnt value than the value returned by getId.
Call __setitem__ with key k, value v.
Invalidate (expire) the transient object.
Causes the transient object container's "before destruct" method related to this object to be called as a side effect.
Return sequence of key elements.
Return sequence of (key, value) elements.
Remove all key/value pairs.
Return value associated with key k. If k does not exist and default is not marker, return default, else raise KeyError.
Merge dictionary d into ourselves.
Returns a meaningful unique id for the object.
Return the time the transient object was last accessed in integer seconds-since-the-epoch form.
Return true if item referenced by key k exists.
Return sequence of value elements.
Return the time the transient object was created in integer seconds-since-the-epoch form.
Cause the last accessed time to be set to now.
Call __delitem__ with key k.
An exception importable from the Products.Transience.Transience module
which is raised when an attempt is made to add an item to a
TransientObjectContainer that is full
.
This exception may be caught in PythonScripts through a normal import. A successful import of the exception can be achieved via:
from Products.Transience import MaxTransientObjectsExceeded