Commit 04d96d0d authored by Chris McDonough's avatar Chris McDonough

Added interface method getContainerKey.

Changed interfaces files to reflect getContainerKey.

Specified permissions in helpsystem interfaces for transient objects.
parent aee1759e
......@@ -85,10 +85,10 @@
"""
Core session tracking SessionData class.
$Id: Transience.py,v 1.19 2001/11/17 22:48:43 chrism Exp $
$Id: Transience.py,v 1.20 2001/11/20 15:29:23 chrism Exp $
"""
__version__='$Revision: 1.19 $'[11:-2]
__version__='$Revision: 1.20 $'[11:-2]
import Globals
from Globals import HTMLFile, MessageDialog
......@@ -618,8 +618,8 @@ class TransientObject(Persistent, Implicit):
# Initializer
#
def __init__(self, id):
self.token = id
def __init__(self, containerkey):
self.token = containerkey
self.id = self._generateUniqueId()
self._container = {}
self._created = self._last_accessed = time()
......@@ -733,9 +733,9 @@ class TransientObject(Persistent, Implicit):
# other objects (eliminates read conflicts).
return 1
getName = getId
getName = getId # this is for SQLSession compatibility
def getToken(self):
def getContainerKey(self):
return self.token
def _generateUniqueId(self):
......
......@@ -173,6 +173,12 @@ class Transient(Interface.Base):
seconds-since-the-epoch form.
"""
def getContainerKey(self):
"""
Return the key under which the object was placed in its
container.
"""
class DictionaryLike(Interface.Base):
def keys(self):
"""
......
......@@ -86,7 +86,7 @@ class TransientObjectContainer(Interface.Base):
You will rarely have to script a transient object
container. You'll almost always deal with a TransientObject
itself which you'll usaually get as 'REQUEST.SESSION'.
itself which you'll usually get as 'REQUEST.SESSION'.
"""
def getId(self):
......@@ -217,14 +217,19 @@ class TransientObject(Interface.Base):
When using a transient object from Python-based Scripts or DTML
you can use the 'get', 'set', and 'delete' methods instead.
It's important to reassign mutuable sub-items when you change
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.
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.
"""
def getId(self):
......@@ -234,6 +239,15 @@ class TransientObject(Interface.Base):
Permission -- Always available
"""
def getContainerKey(self):
"""
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.
Permission -- Always available
"""
def invalidate(self):
"""
Invalidate (expire) the transient object.
......@@ -241,7 +255,7 @@ class TransientObject(Interface.Base):
Causes the transient object container's "before destruct" method
related to this object to be called as a side effect.
Permission -- XXX
Permission -- Always available
"""
def getLastAccessed(self):
......@@ -249,14 +263,14 @@ class TransientObject(Interface.Base):
Return the time the transient object was last accessed in
integer seconds-since-the-epoch form.
Permission -- XXX
Permission -- Always available
"""
def setLastAccessed(self):
"""
Cause the last accessed time to be set to now.
Permission -- XXX
Permission -- Always available
"""
def getCreated(self):
......@@ -264,28 +278,28 @@ class TransientObject(Interface.Base):
Return the time the transient object was created in integer
seconds-since-the-epoch form.
Permission -- XXX
Permission -- Always available
"""
def keys(self):
"""
Return sequence of key elements.
Permission -- XXX
Permission -- Always available
"""
def values(self):
"""
Return sequence of value elements.
Permission -- XXX
Permission -- Always available
"""
def items(self):
"""
Return sequence of (key, value) elements.
Permission -- XXX
Permission -- Always available
"""
def get(self, k, default='marker'):
......@@ -293,42 +307,42 @@ class TransientObject(Interface.Base):
Return value associated with key k. If k does not exist and default
is not marker, return default, else raise KeyError.
Permission -- XXX
Permission -- Always available
"""
def has_key(self, k):
"""
Return true if item referenced by key k exists.
Permission -- XXX
Permission -- Always available
"""
def clear(self):
"""
Remove all key/value pairs.
Permission -- XXX
Permission -- Always available
"""
def update(self, d):
"""
Merge dictionary d into ourselves.
Permission -- XXX
Permission -- Always available
"""
def set(self, k, v):
"""
Call __setitem__ with key k, value v.
Permission -- XXX
Permission -- Always available
"""
def delete(self, k):
"""
Call __delitem__ with key k.
Permission -- XXX
Permission -- Always available
"""
......
......@@ -479,6 +479,9 @@ class TestTransientObjectContainer(TestCase):
def test_getId(self):
assert self.t.getId() == 'sdc'
def test_getContainerKey(self):
t = self.t.new('foobieblech')
assert t.getContainerKey() == 'foobieblech'
def lsubtract(l1, l2):
l1=list(l1)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment