[gen] Adapted all logged messages because thhe logged user is now automatically prepended to any message.
This commit is contained in:
parent
ac1d710288
commit
7889277328
|
@ -675,7 +675,7 @@ class ToolMixin(BaseMixin):
|
||||||
align = self.flipLanguageDirection(align, dir)
|
align = self.flipLanguageDirection(align, dir)
|
||||||
field = self.getAppyType(fieldName, className)
|
field = self.getAppyType(fieldName, className)
|
||||||
if not field:
|
if not field:
|
||||||
self.log('Field "%s", used in a column specifier, was not ' \
|
self.log('field "%s", used in a column specifier, was not ' \
|
||||||
'found.' % fieldName, type='warning')
|
'found.' % fieldName, type='warning')
|
||||||
else:
|
else:
|
||||||
res.append(Object(field=field, width=width, align=align))
|
res.append(Object(field=field, width=width, align=align))
|
||||||
|
@ -1093,14 +1093,14 @@ class ToolMixin(BaseMixin):
|
||||||
msg = self.translate('enable_cookies')
|
msg = self.translate('enable_cookies')
|
||||||
return self.goto(urlBack, msg)
|
return self.goto(urlBack, msg)
|
||||||
# Authenticate the user.
|
# Authenticate the user.
|
||||||
login = rq.get('__ac_name', None)
|
|
||||||
if self.getUser(authentify=True) or \
|
if self.getUser(authentify=True) or \
|
||||||
self.getUser(authentify=True, source='ldap'):
|
self.getUser(authentify=True, source='ldap'):
|
||||||
msg = self.translate('login_ok')
|
msg = self.translate('login_ok')
|
||||||
logMsg = 'User "%s" logged in.' % login
|
logMsg = 'logged in.'
|
||||||
else:
|
else:
|
||||||
msg = self.translate('login_ko')
|
msg = self.translate('login_ko')
|
||||||
logMsg = 'Authentication failed with login "%s".' % login
|
login = rq.get('__ac_name') or '<empty>'
|
||||||
|
logMsg = 'authentication failed with login %s.' % login
|
||||||
self.log(logMsg)
|
self.log(logMsg)
|
||||||
return self.goto(self.getApp().absolute_url(), msg)
|
return self.goto(self.getApp().absolute_url(), msg)
|
||||||
|
|
||||||
|
@ -1120,7 +1120,7 @@ class ToolMixin(BaseMixin):
|
||||||
session = sdm.getSessionData(create=0)
|
session = sdm.getSessionData(create=0)
|
||||||
if session is not None:
|
if session is not None:
|
||||||
session.invalidate()
|
session.invalidate()
|
||||||
self.log('User "%s" has been logged out.' % userId)
|
self.log('logged out.')
|
||||||
# Remove user from variable "loggedUsers"
|
# Remove user from variable "loggedUsers"
|
||||||
if self.loggedUsers.has_key(userId): del self.loggedUsers[userId]
|
if self.loggedUsers.has_key(userId): del self.loggedUsers[userId]
|
||||||
return self.goto(self.getApp().absolute_url())
|
return self.goto(self.getApp().absolute_url())
|
||||||
|
@ -1268,7 +1268,7 @@ class ToolMixin(BaseMixin):
|
||||||
htmlMessage = '<a href="/">Back</a> You are not allowed to ' \
|
htmlMessage = '<a href="/">Back</a> You are not allowed to ' \
|
||||||
'access this page.'
|
'access this page.'
|
||||||
userId = self.appy().user.login
|
userId = self.appy().user.login
|
||||||
textMessage = 'Unauthorized for %s @%s.' % \
|
textMessage = 'unauthorized for %s @%s.' % \
|
||||||
(userId, self.REQUEST.get('PATH_INFO'))
|
(userId, self.REQUEST.get('PATH_INFO'))
|
||||||
else:
|
else:
|
||||||
from zExceptions.ExceptionFormatter import format_exception
|
from zExceptions.ExceptionFormatter import format_exception
|
||||||
|
|
|
@ -178,8 +178,8 @@ class BaseMixin:
|
||||||
history.append(event)
|
history.append(event)
|
||||||
self.workflow_history[key] = tuple(history)
|
self.workflow_history[key] = tuple(history)
|
||||||
appy = self.appy()
|
appy = self.appy()
|
||||||
self.log('Data change event deleted by %s for %s (UID=%s).' % \
|
self.log('data change event deleted for %s (UID=%s).' % \
|
||||||
(appy.user.login, appy.klass.__name__, appy.uid))
|
(appy.klass.__name__, appy.uid))
|
||||||
self.goto(self.getUrl(rq['HTTP_REFERER']))
|
self.goto(self.getUrl(rq['HTTP_REFERER']))
|
||||||
|
|
||||||
def onLink(self):
|
def onLink(self):
|
||||||
|
@ -563,7 +563,11 @@ class BaseMixin:
|
||||||
if type == 'warning': logMethod = logger.warn
|
if type == 'warning': logMethod = logger.warn
|
||||||
elif type == 'error': logMethod = logger.error
|
elif type == 'error': logMethod = logger.error
|
||||||
else: logMethod = logger.info
|
else: logMethod = logger.info
|
||||||
logMethod('%s: %s' % (self.getTool().getUser().login, msg))
|
user = self.getTool().getUser()
|
||||||
|
# There could be not user at all (even not "anon") if we are trying to
|
||||||
|
# authenticate an inexistent user for example.
|
||||||
|
login = user and user.login or 'anon'
|
||||||
|
logMethod('%s: %s' % (login, msg))
|
||||||
|
|
||||||
def do(self):
|
def do(self):
|
||||||
'''Performs some action from the user interface.'''
|
'''Performs some action from the user interface.'''
|
||||||
|
|
|
@ -659,7 +659,7 @@ class ToolWrapper(AbstractWrapper):
|
||||||
convScript = '%s/pod/converter.py' % os.path.dirname(appy.__file__)
|
convScript = '%s/pod/converter.py' % os.path.dirname(appy.__file__)
|
||||||
cmd = '%s %s "%s" %s -p%d' % (self.unoEnabledPython, convScript,
|
cmd = '%s %s "%s" %s -p%d' % (self.unoEnabledPython, convScript,
|
||||||
fileName, format, self.openOfficePort)
|
fileName, format, self.openOfficePort)
|
||||||
self.log('Executing %s...' % cmd)
|
self.log('executing %s...' % cmd)
|
||||||
return executeCommand(cmd) # The result can contain an error message
|
return executeCommand(cmd) # The result can contain an error message
|
||||||
|
|
||||||
def sendMail(self, to, subject, body, attachments=None):
|
def sendMail(self, to, subject, body, attachments=None):
|
||||||
|
@ -682,7 +682,7 @@ class ToolWrapper(AbstractWrapper):
|
||||||
# reindex all Appy-managed objects, ie those in folders "config"
|
# reindex all Appy-managed objects, ie those in folders "config"
|
||||||
# and "data".
|
# and "data".
|
||||||
# First, clear the catalog.
|
# First, clear the catalog.
|
||||||
self.log('Recomputing the whole catalog...')
|
self.log('recomputing the whole catalog...')
|
||||||
app = self.o.getParentNode()
|
app = self.o.getParentNode()
|
||||||
app.catalog._catalog.clear()
|
app.catalog._catalog.clear()
|
||||||
nb = 1
|
nb = 1
|
||||||
|
@ -706,7 +706,7 @@ class ToolWrapper(AbstractWrapper):
|
||||||
failMsg = ' (%d retried)' % len(failed)
|
failMsg = ' (%d retried)' % len(failed)
|
||||||
else:
|
else:
|
||||||
failMsg = ''
|
failMsg = ''
|
||||||
self.log('%d object(s) were reindexed%s.' % (nb, failMsg))
|
self.log('%d object(s) reindexed%s.' % (nb, failMsg))
|
||||||
else:
|
else:
|
||||||
nb = 1
|
nb = 1
|
||||||
failed = []
|
failed = []
|
||||||
|
|
|
@ -79,6 +79,6 @@ class TranslationWrapper(AbstractWrapper):
|
||||||
|
|
||||||
def onDelete(self):
|
def onDelete(self):
|
||||||
# Call a custom "onDelete" if any.
|
# Call a custom "onDelete" if any.
|
||||||
self.log('Translation "%s" deleted by "%s".' % (self.id, self.user.id))
|
self.log('translation "%s" deleted.' % self.id)
|
||||||
return self._callCustom('onDelete')
|
return self._callCustom('onDelete')
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
|
|
|
@ -89,8 +89,7 @@ class UserWrapper(AbstractWrapper):
|
||||||
# user. So update the authentication cookie, too.
|
# user. So update the authentication cookie, too.
|
||||||
gutils.writeCookie(login, newPassword, self.request)
|
gutils.writeCookie(login, newPassword, self.request)
|
||||||
if log:
|
if log:
|
||||||
self.log('Password %s by "%s" for "%s".' % \
|
self.log('password %s for %s.' % (msgPart, login))
|
||||||
(msgPart, self.user.login, login))
|
|
||||||
return newPassword
|
return newPassword
|
||||||
|
|
||||||
def setEncryptedPassword(self, encryptedPassword):
|
def setEncryptedPassword(self, encryptedPassword):
|
||||||
|
@ -128,9 +127,8 @@ class UserWrapper(AbstractWrapper):
|
||||||
self.compute(className, context=context, noSecurity=True,
|
self.compute(className, context=context, noSecurity=True,
|
||||||
expression="ctx['nb'] += obj.o.applyUserIdChange(" \
|
expression="ctx['nb'] += obj.o.applyUserIdChange(" \
|
||||||
"ctx['old'], ctx['new'])")
|
"ctx['old'], ctx['new'])")
|
||||||
self.log("Login '%s' renamed to '%s' by '%s'." % \
|
self.log("login %s renamed to %s." % (oldLogin, newLogin))
|
||||||
(oldLogin, newLogin, self.user.login))
|
self.log('login change: local roles updated in %d object(s).' % \
|
||||||
self.log('Login change: local roles updated in %d object(s).' % \
|
|
||||||
context['nb'])
|
context['nb'])
|
||||||
|
|
||||||
def getGrantableRoles(self):
|
def getGrantableRoles(self):
|
||||||
|
@ -244,7 +242,7 @@ class UserWrapper(AbstractWrapper):
|
||||||
'''Before deleting myself, I must delete the corresponding Zope user
|
'''Before deleting myself, I must delete the corresponding Zope user
|
||||||
(for local users only).'''
|
(for local users only).'''
|
||||||
if self.source == 'zodb': del self.o.acl_users.data[self.login]
|
if self.source == 'zodb': del self.o.acl_users.data[self.login]
|
||||||
self.log('User "%s" deleted.' % self.login)
|
self.log('user %s deleted.' % self.login)
|
||||||
# Call a custom "onDelete" if any.
|
# Call a custom "onDelete" if any.
|
||||||
return self._callCustom('onDelete')
|
return self._callCustom('onDelete')
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue