[gen] Adapted all logged messages because thhe logged user is now automatically prepended to any message.

This commit is contained in:
Gaetan Delannay 2014-09-01 14:14:32 +02:00
parent ac1d710288
commit 7889277328
5 changed files with 21 additions and 19 deletions

View file

@ -675,7 +675,7 @@ class ToolMixin(BaseMixin):
align = self.flipLanguageDirection(align, dir)
field = self.getAppyType(fieldName, className)
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')
else:
res.append(Object(field=field, width=width, align=align))
@ -1093,14 +1093,14 @@ class ToolMixin(BaseMixin):
msg = self.translate('enable_cookies')
return self.goto(urlBack, msg)
# Authenticate the user.
login = rq.get('__ac_name', None)
if self.getUser(authentify=True) or \
self.getUser(authentify=True, source='ldap'):
msg = self.translate('login_ok')
logMsg = 'User "%s" logged in.' % login
logMsg = 'logged in.'
else:
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)
return self.goto(self.getApp().absolute_url(), msg)
@ -1120,7 +1120,7 @@ class ToolMixin(BaseMixin):
session = sdm.getSessionData(create=0)
if session is not None:
session.invalidate()
self.log('User "%s" has been logged out.' % userId)
self.log('logged out.')
# Remove user from variable "loggedUsers"
if self.loggedUsers.has_key(userId): del self.loggedUsers[userId]
return self.goto(self.getApp().absolute_url())
@ -1268,7 +1268,7 @@ class ToolMixin(BaseMixin):
htmlMessage = '<a href="/">Back</a> You are not allowed to ' \
'access this page.'
userId = self.appy().user.login
textMessage = 'Unauthorized for %s @%s.' % \
textMessage = 'unauthorized for %s @%s.' % \
(userId, self.REQUEST.get('PATH_INFO'))
else:
from zExceptions.ExceptionFormatter import format_exception

View file

@ -178,8 +178,8 @@ class BaseMixin:
history.append(event)
self.workflow_history[key] = tuple(history)
appy = self.appy()
self.log('Data change event deleted by %s for %s (UID=%s).' % \
(appy.user.login, appy.klass.__name__, appy.uid))
self.log('data change event deleted for %s (UID=%s).' % \
(appy.klass.__name__, appy.uid))
self.goto(self.getUrl(rq['HTTP_REFERER']))
def onLink(self):
@ -563,7 +563,11 @@ class BaseMixin:
if type == 'warning': logMethod = logger.warn
elif type == 'error': logMethod = logger.error
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):
'''Performs some action from the user interface.'''

View file

@ -659,7 +659,7 @@ class ToolWrapper(AbstractWrapper):
convScript = '%s/pod/converter.py' % os.path.dirname(appy.__file__)
cmd = '%s %s "%s" %s -p%d' % (self.unoEnabledPython, convScript,
fileName, format, self.openOfficePort)
self.log('Executing %s...' % cmd)
self.log('executing %s...' % cmd)
return executeCommand(cmd) # The result can contain an error message
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"
# and "data".
# First, clear the catalog.
self.log('Recomputing the whole catalog...')
self.log('recomputing the whole catalog...')
app = self.o.getParentNode()
app.catalog._catalog.clear()
nb = 1
@ -706,7 +706,7 @@ class ToolWrapper(AbstractWrapper):
failMsg = ' (%d retried)' % len(failed)
else:
failMsg = ''
self.log('%d object(s) were reindexed%s.' % (nb, failMsg))
self.log('%d object(s) reindexed%s.' % (nb, failMsg))
else:
nb = 1
failed = []

View file

@ -79,6 +79,6 @@ class TranslationWrapper(AbstractWrapper):
def onDelete(self):
# 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')
# ------------------------------------------------------------------------------

View file

@ -89,8 +89,7 @@ class UserWrapper(AbstractWrapper):
# user. So update the authentication cookie, too.
gutils.writeCookie(login, newPassword, self.request)
if log:
self.log('Password %s by "%s" for "%s".' % \
(msgPart, self.user.login, login))
self.log('password %s for %s.' % (msgPart, login))
return newPassword
def setEncryptedPassword(self, encryptedPassword):
@ -128,9 +127,8 @@ class UserWrapper(AbstractWrapper):
self.compute(className, context=context, noSecurity=True,
expression="ctx['nb'] += obj.o.applyUserIdChange(" \
"ctx['old'], ctx['new'])")
self.log("Login '%s' renamed to '%s' by '%s'." % \
(oldLogin, newLogin, self.user.login))
self.log('Login change: local roles updated in %d object(s).' % \
self.log("login %s renamed to %s." % (oldLogin, newLogin))
self.log('login change: local roles updated in %d object(s).' % \
context['nb'])
def getGrantableRoles(self):
@ -244,7 +242,7 @@ class UserWrapper(AbstractWrapper):
'''Before deleting myself, I must delete the corresponding Zope user
(for local users only).'''
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.
return self._callCustom('onDelete')