changeset 6075:3f7f4cef7c2a

make log_attempt output easily parsed
author 'Karl O. Pinc' <kop@meme.com>
date Mon, 15 Sep 2014 21:53:09 -0500
parents 6366f5b440ff
children f4ec84967c27
files MoinMoin/PageEditor.py MoinMoin/action/edit.py MoinMoin/action/newpage.py MoinMoin/action/revert.py MoinMoin/auth/__init__.py MoinMoin/events/__init__.py MoinMoin/util/abuse.py MoinMoin/wsgiapp.py
diffstat 8 files changed, 23 insertions(+), 23 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/PageEditor.py	Mon Sep 15 21:27:54 2014 -0500
+++ b/MoinMoin/PageEditor.py	Mon Sep 15 21:53:09 2014 -0500
@@ -169,11 +169,11 @@
 
         # check edit permissions
         if not request.user.may.write(self.page_name):
-            log_attempt('edit: no permissions', False, request,
+            log_attempt('edit/no permissions', False, request,
                         pagename=self.page_name)
             msg = _('You are not allowed to edit this page.')
         elif not self.isWritable():
-            log_attempt('edit: immutable', False, request,
+            log_attempt('edit/immutable', False, request,
                         pagename=self.page_name)
             msg = _('Page is immutable!')
         elif self.rev:
@@ -556,7 +556,7 @@
             return False, _("You can't copy to an empty pagename.")
 
         if not self.request.user.may.write(newpagename):
-            log_attempt('copy: no permissions', False, request,
+            log_attempt('copy/no permissions', False, request,
                         pagename=self.page_name)
             return False, _('You are not allowed to copy this page!')
 
@@ -610,7 +610,7 @@
 
         if not (request.user.may.delete(self.page_name)
                 and request.user.may.write(newpagename)):
-            log_attempt('rename: no permissions', False, request,
+            log_attempt('rename/no permissions', False, request,
                         pagename=self.page_name)
             msg = _('You are not allowed to rename this page!')
             raise self.AccessDenied(msg)
@@ -719,7 +719,7 @@
         success = True
         if not (request.user.may.write(self.page_name)
                 and request.user.may.delete(self.page_name)):
-            log_attempt('delete: no permissions', False, request,
+            log_attempt('delete/no permissions', False, request,
                         pagename=self.page_name)
             msg = _('You are not allowed to delete this page!')
             raise self.AccessDenied(msg)
@@ -1085,12 +1085,12 @@
 
         msg = ""
         if not request.user.may.save(self, newtext, rev, **kw):
-            log_attempt('save: no permissions', False, request,
+            log_attempt('save/no permissions', False, request,
                         pagename=self.page_name)
             msg = _('You are not allowed to edit this page!')
             raise self.AccessDenied(msg)
         elif not self.isWritable():
-            log_attempt('edit: immutable', False, request,
+            log_attempt('edit/immutable', False, request,
                         pagename=self.page_name)
             msg = _('Page is immutable!')
             raise self.Immutable(msg)
@@ -1135,7 +1135,7 @@
             if (not request.user.may.admin(self.page_name) and
                 parseACL(request, newtext).acl != acl.acl and
                 action != "SAVE/REVERT"):
-                log_attempt('acl change: no permissions', False, request,
+                log_attempt('acl change/no permissions', False, request,
                             pagename=self.page_name)
                 msg = _("You can't change ACLs on this page since you have no admin rights on it!")
                 raise self.NoAdmin(msg)
--- a/MoinMoin/action/edit.py	Mon Sep 15 21:27:54 2014 -0500
+++ b/MoinMoin/action/edit.py	Mon Sep 15 21:53:09 2014 -0500
@@ -23,7 +23,7 @@
         return
 
     if not request.user.may.write(pagename):
-        log_attempt('edit: no permissions', False, request, pagename=pagename)
+        log_attempt('edit/no permissions', False, request, pagename=pagename)
         page = wikiutil.getLocalizedPage(request, 'PermissionDeniedPage')
         page.body = _('You are not allowed to edit this page.')
         page.page_name = pagename
--- a/MoinMoin/action/newpage.py	Mon Sep 15 21:27:54 2014 -0500
+++ b/MoinMoin/action/newpage.py	Mon Sep 15 21:53:09 2014 -0500
@@ -66,7 +66,7 @@
         page = Page(self.request, self.pagename)
         if not (page.isWritable() and self.request.user.may.read(self.pagename)):
             # Same error as the edit page for localization reasons
-            log_attempt('newpage: immutable or no permissions', False,
+            log_attempt('newpage/immutable or no permissions', False,
                         self.request, pagename=self.pagename)
             return _('You are not allowed to edit this page.')
         return ''
--- a/MoinMoin/action/revert.py	Mon Sep 15 21:27:54 2014 -0500
+++ b/MoinMoin/action/revert.py	Mon Sep 15 21:53:09 2014 -0500
@@ -34,7 +34,7 @@
         may = self.request.user.may
         allowed = may.write(self.pagename) and may.revert(self.pagename)
         if not allowed:
-            log_attempt('revert: immutable or no permissions', False,
+            log_attempt('revert/immutable or no permissions', False,
                         self.request, pagename=self.pagename)
         return allowed, _('You are not allowed to revert this page!')
 
--- a/MoinMoin/auth/__init__.py	Mon Sep 15 21:27:54 2014 -0500
+++ b/MoinMoin/auth/__init__.py	Mon Sep 15 21:53:09 2014 -0500
@@ -252,11 +252,11 @@
         u = user.User(request, name=username, password=password, auth_method=self.name)
         if u.valid:
             logging.debug("%s: successfully authenticated user %r (valid)" % (self.name, u.name))
-            log_attempt("auth: login (moin)", True, request, username)
+            log_attempt("auth/login (moin)", True, request, username)
             return ContinueLogin(u)
         else:
             logging.debug("%s: could not authenticate user %r (not valid)" % (self.name, username))
-            log_attempt("auth: login (moin)", False, request, username)
+            log_attempt("auth/login (moin)", False, request, username)
             return ContinueLogin(user_obj, _("Invalid username or password."))
 
     def login_hint(self, request):
@@ -379,12 +379,12 @@
             u.create_or_update()
         if u and u.valid:
             logging.debug("returning valid user %r" % u)
-            log_attempt("auth: request (given)", True, request, auth_username)
+            log_attempt("auth/request (given)", True, request, auth_username)
             return u, True # True to get other methods called, too
         else:
             logging.debug("returning %r" % user_obj)
             if u and not u.valid:
-                log_attempt("auth: request (given)", False, request, auth_username)
+                log_attempt("auth/request (given)", False, request, auth_username)
             return user_obj, True
 
 
@@ -474,7 +474,7 @@
         uid = request.session['setuid']
         userobj = user.User(request, uid, auth_method='setuid')
         userobj.valid = True
-        log_attempt("auth: login (setuid from %r)" % old_user.name,
+        log_attempt("auth/login (setuid from %r)" % old_user.name,
                     True, request, userobj.name)
     logging.debug("setup_suid returns %r, %r" % (userobj, old_user))
     return (userobj, old_user)
--- a/MoinMoin/events/__init__.py	Mon Sep 15 21:27:54 2014 -0500
+++ b/MoinMoin/events/__init__.py	Mon Sep 15 21:53:09 2014 -0500
@@ -187,7 +187,7 @@
     req_superuser = True
 
     def __init__(self, request, user):
-        log_attempt('event: newaccount', True, request, user.name)
+        log_attempt('event/newaccount', True, request, user.name)
         Event.__init__(self, request)
         self.user = user
 
--- a/MoinMoin/util/abuse.py	Mon Sep 15 21:27:54 2014 -0500
+++ b/MoinMoin/util/abuse.py	Mon Sep 15 21:53:09 2014 -0500
@@ -19,7 +19,7 @@
     log attempts to use <system>, log success / failure / username / ip
 
     @param system: some string telling about the system that was used, e.g.
-                   "auth: login" or "textcha"
+                   "auth/login" or "textcha"
     @param success: whether the attempt was successful
     @param request: request object (optional, to determine remote's ip address)
     @param username: user's name (optional, if None: determined from request)
@@ -31,7 +31,7 @@
         else:
             username = u'anonymous'
     level = (logging.WARNING, logging.INFO)[success]
-    msg = """%s status: %s username: "%s" ip: %s page: %s"""
+    msg = """%s: status %s: username "%s": ip %s: page %s"""
     status = ("failure", "success")[success]
     ip = request and request.remote_addr or 'unknown'
     logging.log(level, msg, system, status, username, ip, pagename)
--- a/MoinMoin/wsgiapp.py	Mon Sep 15 21:27:54 2014 -0500
+++ b/MoinMoin/wsgiapp.py	Mon Sep 15 21:53:09 2014 -0500
@@ -174,10 +174,10 @@
         msg = _("You are not allowed to do %(action_name)s on this page.") % {
                 'action_name': wikiutil.escape(action_name), }
         if context.user.valid:
-            log_attempt(action_name + ': action unavailable', False, request,
+            log_attempt(action_name + '/action unavailable', False, request,
                         context.user.name, pagename=pagename)
         else:
-            log_attempt(action_name + ': action unavailable', False, request,
+            log_attempt(action_name + '/action unavailable', False, request,
                         pagename=pagename)
             # Suggest non valid user to login
             msg += " " + _("Login and try again.")
@@ -193,10 +193,10 @@
             msg = _("You are not allowed to do %(action_name)s on this page.") % {
                     'action_name': wikiutil.escape(action_name), }
             if context.user.valid:
-                log_attempt(action_name + ': no handler', False, request,
+                log_attempt(action_name + '/no handler', False, request,
                             context.user.name, pagename=pagename)
             else:
-                log_attempt(action_name + ': no handler', False, request,
+                log_attempt(action_name + '/no handler', False, request,
                             pagename=pagename)
                 # Suggest non valid user to login
                 msg += " " + _("Login and try again.")