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
9266ec06
Commit
9266ec06
authored
May 12, 2004
by
Andreas Jung
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
death to zLOG
parent
d0138823
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
25 deletions
+20
-25
lib/python/Products/Transience/Transience.py
lib/python/Products/Transience/Transience.py
+11
-15
lib/python/Products/Transience/TransientObject.py
lib/python/Products/Transience/TransientObject.py
+9
-10
No files found.
lib/python/Products/Transience/Transience.py
View file @
9266ec06
...
...
@@ -33,11 +33,11 @@ from AccessControl.User import nobody
from
BTrees.OOBTree
import
OOBTree
,
OOBucket
,
OOSet
from
BTrees.IOBTree
import
IOBTree
from
BTrees.Length
import
Length
from
zLOG
import
LOG
,
WARNING
,
BLATHER
import
os.path
import
os
import
math
,
sys
,
random
import
time
import
logging
from
types
import
InstanceType
from
TransientObject
import
TransientObject
import
thread
...
...
@@ -48,6 +48,7 @@ from cgi import escape
_marker
=
[]
DEBUG
=
os
.
environ
.
get
(
'Z_TOC_DEBUG'
,
''
)
LOG
=
getLogger
(
'Zope.Transience'
)
class
MaxTransientObjectsExceeded
(
Exception
):
pass
...
...
@@ -69,7 +70,7 @@ def TLOG(*args):
sargs
.
append
(
str
(
time
.
time
()))
for
arg
in
args
:
sargs
.
append
(
str
(
arg
))
LOG
(
'Transience'
,
BLATHER
,
' '
.
join
(
sargs
))
LOG
.
debug
(
' '
.
join
(
sargs
))
def
constructTransientObjectContainer
(
self
,
id
,
title
=
''
,
timeout_mins
=
20
,
addNotification
=
None
,
delNotification
=
None
,
limit
=
0
,
REQUEST
=
None
):
...
...
@@ -266,11 +267,9 @@ class TransientObjectContainer(SimpleItem):
except
(
KeyError
,
AttributeError
):
path
=
self
.
getPhysicalPath
()
err
=
'No such method %s in %s %s'
LOG
(
'Transience'
,
WARNING
,
err
%
(
callback
,
'/'
.
join
(
path
),
name
),
error
=
sys
.
exc_info
()
)
LOG
.
warn
(
err
%
(
callback
,
'/'
.
join
(
path
),
name
),
exc_info
=
sys
.
exc_info
()
)
return
else
:
method
=
callback
...
...
@@ -286,22 +285,19 @@ class TransientObjectContainer(SimpleItem):
except
:
# dont raise, just log
path
=
self
.
getPhysicalPath
()
LOG
(
'Transience'
,
WARNING
,
LOG
.
warn
(
'%s failed when calling %s in %s'
%
(
name
,
callback
,
'/'
.
join
(
path
)),
e
rror
=
sys
.
exc_info
()
e
xc_info
=
sys
.
exc_info
()
)
finally
:
setSecurityManager
(
sm
)
else
:
err
=
'%s in %s attempted to call non-callable %s'
path
=
self
.
getPhysicalPath
()
LOG
(
'Transience'
,
WARNING
,
err
%
(
name
,
'/'
.
join
(
path
),
callback
),
error
=
sys
.
exc_info
()
)
LOG
.
warn
(
err
%
(
name
,
'/'
.
join
(
path
),
callback
),
exc_info
=
sys
.
exc_info
()
)
security
.
declareProtected
(
MANAGE_CONTAINER_PERM
,
'manage_changeTransientObjectContainer'
)
...
...
lib/python/Products/Transience/TransientObject.py
View file @
9266ec06
...
...
@@ -26,12 +26,13 @@ from TransienceInterfaces import ItemWithId, Transient, DictionaryLike,\
TransientItemContainer
from
AccessControl
import
ClassSecurityInfo
import
Globals
from
zLOG
import
LOG
,
BLATHER
,
INFO
import
sys
import
logging
_notfound
=
[]
WRITEGRANULARITY
=
30
# Timing granularity for access write clustering, seconds
LOG
=
logging
.
getLogger
(
'Zope.Transience'
)
class
TransientObject
(
Persistent
,
Implicit
):
""" Dictionary-like object that supports additional methods
...
...
@@ -192,7 +193,7 @@ class TransientObject(Persistent, Implicit):
return
1
def
_p_resolveConflict
(
self
,
saved
,
state1
,
state2
):
LOG
(
'Transience'
,
BLATHER
,
'Resolving conflict in TransientObject'
)
LOG
.
debug
(
'Resolving conflict in TransientObject'
)
try
:
states
=
[
saved
,
state1
,
state2
]
...
...
@@ -200,7 +201,7 @@ class TransientObject(Persistent, Implicit):
# because it's a terminal state.
for
state
in
states
:
if
state
.
has_key
(
'_invalid'
):
LOG
(
'Transience'
,
BLATHER
,
'a state was invalid'
)
LOG
.
debug
(
'a state was invalid'
)
return
state
# The only other times we can clearly resolve the conflict is if
# the token, the id, or the creation time don't differ between
...
...
@@ -210,7 +211,7 @@ class TransientObject(Persistent, Implicit):
attrs
=
[
'token'
,
'id'
,
'_created'
]
for
attr
in
attrs
:
if
not
(
saved
.
get
(
attr
)
==
state1
.
get
(
attr
)
==
state2
.
get
(
attr
)):
LOG
(
'Transience'
,
BLATHER
,
'cant resolve conflict'
)
LOG
.
debug
(
'cant resolve conflict'
)
return
None
# Now we need to do real work.
...
...
@@ -227,7 +228,7 @@ class TransientObject(Persistent, Implicit):
# possible.
states
.
sort
(
lastmodified_sort
)
if
states
[
0
].
get
(
'_last_modified'
):
LOG
(
'Transience'
,
BLATHER
,
'returning last mod state'
)
LOG
.
debug
(
'returning last mod state'
)
return
states
[
0
]
# If we can't determine which object to return on the basis
...
...
@@ -236,13 +237,11 @@ class TransientObject(Persistent, Implicit):
# our parent). This will return an essentially arbitrary state if
# all last_accessed values are equal.
states
.
sort
(
lastaccessed_sort
)
LOG
(
'Transience'
,
BLATHER
,
'returning last_accessed state'
)
LOG
.
debug
(
'returning last_accessed state'
)
return
states
[
0
]
except
:
LOG
(
'Transience'
,
INFO
,
'Conflict resolution error in TransientObject'
,
''
,
sys
.
exc_info
()
)
LOG
.
info
(
'Conflict resolution error in TransientObject'
,
exc_info
=
sys
.
exc_info
())
getName
=
getId
# this is for SQLSession compatibility
...
...
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