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
b322ada0
Commit
b322ada0
authored
Nov 26, 2001
by
Chris McDonough
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Removed unnecessary imports. Removed some debugging code. Tests now pass on Cygwin.
parent
adfa2e91
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
36 deletions
+16
-36
lib/python/Products/Transience/Transience.py
lib/python/Products/Transience/Transience.py
+10
-30
lib/python/Products/Transience/TransientObject.py
lib/python/Products/Transience/TransientObject.py
+3
-3
lib/python/Products/Transience/tests/testTransientObjectContainer.py
...Products/Transience/tests/testTransientObjectContainer.py
+3
-3
No files found.
lib/python/Products/Transience/Transience.py
View file @
b322ada0
...
...
@@ -85,13 +85,13 @@
"""
Transient Object Container class.
$Id: Transience.py,v 1.2
1 2001/11/21 22:46:3
6 chrism Exp $
$Id: Transience.py,v 1.2
2 2001/11/26 15:29:2
6 chrism Exp $
"""
__version__
=
'$Revision: 1.2
1
$'
[
11
:
-
2
]
__version__
=
'$Revision: 1.2
2
$'
[
11
:
-
2
]
import
Globals
from
Globals
import
HTMLFile
,
MessageDialog
from
Globals
import
HTMLFile
from
TransienceInterfaces
import
ItemWithId
,
\
StringKeyedHomogeneousItemContainer
,
TransientItemContainer
from
TransientObject
import
TransientObject
...
...
@@ -99,12 +99,11 @@ from OFS.SimpleItem import SimpleItem
from
Persistence
import
Persistent
from
AccessControl
import
ClassSecurityInfo
,
getSecurityManager
from
AccessControl.SecurityManagement
import
newSecurityManager
import
AccessControl.SpecialUsers
from
AccessControl.User
import
nobody
from
BTrees
import
OOBTree
from
BTrees.Length
import
Length
from
zLOG
import
LOG
,
WARNING
,
BLATHER
import
os
,
os
.
path
,
math
,
time
,
sys
,
random
import
os
,
math
,
time
,
sys
,
random
DEBUG
=
os
.
environ
.
get
(
'Z_TOC_DEBUG'
,
''
)
...
...
@@ -408,12 +407,11 @@ class TransientObjectContainer(SimpleItem):
try
:
self
.
__len__
.
set
(
0
)
except
AttributeError
:
self
.
__len__
=
self
.
getLen
=
Length
()
def
_getCurrentBucket
(
self
,
get_dump
=
0
):
def
_getCurrentBucket
(
self
):
# no timeout always returns last bucket
if
not
self
.
_timeout_secs
:
DEBUG
and
DLOG
(
'no timeout, returning first bucket'
)
b
,
dump_after
=
self
.
_ring
.
_data
[
0
]
if
DEBUG
:
DLOG
(
'no timeout, returning first bucket'
)
return
b
index
=
self
.
_ring
.
_index
now
=
int
(
time
.
time
())
...
...
@@ -425,9 +423,8 @@ class TransientObjectContainer(SimpleItem):
while
1
:
l
=
b
,
dump_after
=
self
.
_ring
.
_data
[
-
1
]
if
now
>
dump_after
:
if
DEBUG
:
DLOG
(
'now is %s'
%
now
)
DLOG
(
'dump_after for %s was %s, dumping'
%
(
b
,
dump_after
))
DEBUG
and
DLOG
(
'dumping... now is %s'
%
now
)
DEBUG
and
DLOG
(
'dump_after for %s was %s'
%
(
b
,
dump_after
))
self
.
_ring
.
turn
()
# mutate elements in-place in the ring
new_dump_after
=
now
+
i
...
...
@@ -437,11 +434,8 @@ class TransientObjectContainer(SimpleItem):
else
:
break
if
to_clean
:
self
.
_clean
(
to_clean
,
index
)
if
get_dump
:
return
self
.
_ring
.
_data
[
0
],
dump_after
,
now
else
:
b
,
dump_after
=
self
.
_ring
.
_data
[
0
]
return
b
b
,
dump_after
=
self
.
_ring
.
_data
[
0
]
return
b
def
_clean
(
self
,
bucket_set
,
index
):
# Build a reverse index. Eventually, I'll keep this in another
...
...
@@ -474,20 +468,6 @@ class TransientObjectContainer(SimpleItem):
# finalize em
self
.
notifyDestruct
(
trans_obs
)
def
_show
(
self
):
""" debug method """
b
,
dump
,
now
=
self
.
_getCurrentBucket
(
1
)
ringdumps
=
map
(
lambda
x
:
`x[1]`
[
-
4
],
self
.
_ring
)
t
=
(
"now: "
+
`now`
[
-
4
:],
"dump_after: "
+
`dump`
[
-
4
:],
"ring_dumps: "
+
`ringdumps`
,
"ring: "
+
`self._ring`
)
for
x
in
t
:
print
x
security
.
declareProtected
(
MGMT_SCREEN_PERM
,
'nudge'
)
def
nudge
(
self
):
""" Used by mgmt interface to turn the bucket set each time
...
...
lib/python/Products/Transience/TransientObject.py
View file @
b322ada0
...
...
@@ -85,13 +85,13 @@
"""
Simple ZODB-based transient object implementation.
$Id: TransientObject.py,v 1.
1 2001/11/21 22:46:36
chrism Exp $
$Id: TransientObject.py,v 1.
2 2001/11/26 15:29:27
chrism Exp $
"""
__version__
=
'$Revision: 1.
1
$'
[
11
:
-
2
]
__version__
=
'$Revision: 1.
2
$'
[
11
:
-
2
]
from
Persistence
import
Persistent
from
Acquisition
import
Implicit
,
aq_base
from
Acquisition
import
Implicit
import
time
,
random
,
sys
from
TransienceInterfaces
import
ItemWithId
,
Transient
,
DictionaryLike
,
\
TTWDictionary
,
ImmutablyValuedMappingOfPickleableObjects
...
...
lib/python/Products/Transience/tests/testTransientObjectContainer.py
View file @
b322ada0
...
...
@@ -384,7 +384,7 @@ class TestTransientObjectContainer(TestCase):
self
.
t
.
_reset
()
for
x
in
range
(
10
,
110
):
self
.
t
[
x
]
=
x
fauxtime
.
sleep
(
self
.
timeout
*
(
self
.
errmargin
+
1
)
)
fauxtime
.
sleep
(
self
.
timeout
)
assert
len
(
self
.
t
.
keys
())
==
100
,
len
(
self
.
t
.
keys
())
fauxtime
.
sleep
(
self
.
timeout
*
(
self
.
errmargin
+
1
))
assert
len
(
self
.
t
.
keys
())
==
0
,
len
(
self
.
t
.
keys
())
...
...
@@ -394,9 +394,9 @@ class TestTransientObjectContainer(TestCase):
self
.
t
.
_reset
()
for
x
in
range
(
10
,
110
):
self
.
t
[
x
]
=
x
fauxtime
.
sleep
(
self
.
timeout
*
(
self
.
errmargin
+
1
)
)
fauxtime
.
sleep
(
self
.
timeout
)
assert
len
(
self
.
t
.
keys
())
==
100
,
len
(
self
.
t
.
keys
())
fauxtime
.
sleep
(
self
.
timeout
*
(
self
.
errmargin
+
1
)
)
fauxtime
.
sleep
(
self
.
timeout
)
assert
len
(
self
.
t
.
keys
())
==
100
,
len
(
self
.
t
.
keys
())
fauxtime
.
sleep
(
self
.
timeout
*
(
self
.
errmargin
+
1
))
assert
len
(
self
.
t
.
keys
())
==
0
,
len
(
self
.
t
.
keys
())
...
...
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