Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
Zope
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
Zope
Commits
7fa754c9
Commit
7fa754c9
authored
Oct 16, 2001
by
Chris McDonough
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Initial revision
parent
96b46134
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
193 additions
and
0 deletions
+193
-0
lib/python/Products/Transience/TransienceInterfaces.py
lib/python/Products/Transience/TransienceInterfaces.py
+193
-0
lib/python/Products/Transience/__init__.py
lib/python/Products/Transience/__init__.py
+0
-0
No files found.
lib/python/Products/Transience/TransienceInterfaces.py
0 → 100644
View file @
7fa754c9
"""
Transient object and transient object container interfaces.
"""
import
Interface
class
Transient
(
Interface
.
Base
):
def
invalidate
(
self
):
"""
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.
"""
def
getLastAccessed
(
self
):
"""
Return the time the transient object was last accessed in
integer seconds-since-the-epoch form.
"""
def
setLastAccessed
(
self
):
"""
Cause the last accessed time to be set to now.
"""
def
getCreated
(
self
):
"""
Return the time the transient object was created in integer
seconds-since-the-epoch form.
"""
class
DictionaryLike
(
Interface
.
Base
):
def
keys
(
self
):
"""
Return sequence of key elements.
"""
def
values
(
self
):
"""
Return sequence of value elements.
"""
def
items
(
self
):
"""
Return sequence of (key, value) elements.
"""
def
get
(
self
,
k
,
default
=
'marker'
):
"""
Return value associated with key k. If k does not exist and default
is not marker, return default, else raise KeyError.
"""
def
has_key
(
self
,
k
):
"""
Return true if item referenced by key k exists.
"""
def
clear
(
self
):
"""
Remove all key/value pairs.
"""
def
update
(
self
,
d
):
"""
Merge dictionary d into ourselves.
"""
class
ItemWithId
(
Interface
.
Base
):
def
getId
(
self
):
"""
Returns a meaningful unique id for the object.
"""
class
TTWDictionary
(
DictionaryLike
,
ItemWithId
):
def
set
(
self
,
k
,
v
):
"""
Call __setitem__ with key k, value v.
"""
def
delete
(
self
,
k
):
"""
Call __delitem__ with key k.
"""
def
__guarded_setitem__
(
self
,
k
,
v
):
"""
Call __setitem__ with key k, value v.
"""
class
ImmutablyValuedMappingOfPickleableObjects
(
Interface
.
Base
):
def
__setitem__
(
self
,
k
,
v
):
"""
Sets key k to value v, if k is both hashable and pickleable and
v is pickleable, else raise TypeError.
"""
def
__getitem__
(
self
,
k
):
"""
Returns the value associated with key k.
Note that no guarantee is made to persist changes made to mutable
objects obtained via __getitem__, even if they support the
ZODB Persistence interface. In order to ensure that changes to
mutable values are persisted, you need to explicitly put the value back
in to the mapping via __setitem__.
"""
def
__delitem__
(
self
,
k
):
"""
Remove the key/value pair related to key k.
"""
class
HomogeneousItemContainer
(
Interface
.
Base
):
"""
An object which:
1. Contains zero or more subobjects, all of the same type.
2. Is responsible for the creation of its subobjects.
3. Allows for the access of a subobject by key.
"""
def
getSubobjectInterface
(
self
):
"""
Returns the interface object which must be supported by items added
to or created by this container.
"""
def
get
(
self
,
k
,
default
=
None
):
"""
Return value associated with key k. If value associated with k does
not exist, return default.
"""
def
has_key
(
self
,
k
):
"""
Return true if container has value associated with key k, else
return false.
"""
def
delete
(
self
,
k
):
"""
Delete value associated with key k, raise a KeyError if nonexistent.
"""
class
StringKeyedHomogeneousItemContainer
(
HomogeneousItemContainer
):
def
set
(
self
,
k
,
v
):
"""
Sets key k to value v. "k" must be a string, and "v" must support
the homogenous item container's subobject interface; a TypeError
is raised if either condition is untrue.
"""
def
new
(
self
,
k
):
"""
Creates a new subobject of the type supported by this container
with key "k". "k" must be a string else a TypeError is raised.
"""
class
TransientItemContainer
(
Interface
.
Base
):
def
setTimeoutMinutes
(
self
,
timeout_mins
):
"""
Set the number of minutes of inactivity allowable for subobjects
before they expire.
"""
def
getTimeoutMinutes
(
self
):
"""
Return the number of minutes allowed for subobject inactivity
before expiration.
"""
def
setExecuteAfterAddFunc
(
self
,
f
):
"""
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.
"""
def
setExecuteBeforeDestructFunc
(
self
,
f
):
"""
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.
"""
lib/python/Products/Transience/__init__.py
0 → 100644
View file @
7fa754c9
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment