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

death to zLOG

parent d0138823
......@@ -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)),
error=sys.exc_info()
exc_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')
......
......@@ -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
......
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