Commit 9266ec06 authored by Andreas Jung's avatar Andreas Jung

death to zLOG

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