changeset 4829:9d510417add0

Groups2009: Instead of checking that some group is defined in a request.groups and then check that some member is in that group request.groups.get method is used.
author Dmitrijs Milajevs <dimazest@gmail.com>
date Sat, 27 Jun 2009 13:11:35 +0200
parents 0f86a6c578e3
children 069aac5ce3e4
files MoinMoin/action/serveopenid.py MoinMoin/script/migration/wikiutil160a.py MoinMoin/security/autoadmin.py MoinMoin/security/textcha.py MoinMoin/userprefs/oidserv.py
diffstat 5 files changed, 7 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/action/serveopenid.py	Sat Jun 27 13:07:36 2009 +0200
+++ b/MoinMoin/action/serveopenid.py	Sat Jun 27 13:11:35 2009 +0200
@@ -141,10 +141,8 @@
 
         # again, we never put an openid.server link on this page...
         # why are they here?
-        groups = request.groups
         openid_group_name = cfg.openid_server_restricted_users_group
-        if openid_group_name and \
-                not (openid_group_name in groups and received_name in groups[openid_group_name]):
+        if openid_group_name and received_name not in request.groups.get(openid_group_name, []):
             return False
 
         return True
--- a/MoinMoin/script/migration/wikiutil160a.py	Sat Jun 27 13:07:36 2009 +0200
+++ b/MoinMoin/script/migration/wikiutil160a.py	Sat Jun 27 13:11:35 2009 +0200
@@ -648,8 +648,7 @@
     @rtype: bool
     @return: true if page is a system page
     """
-    groups = request.groups
-    return ((u'SystemPagesGroup' in groups and pagename in groups[u'SystemPagesGroup']) or
+    return (pagename in request.groups.get(u'SystemPagesGroup', []) or
         isTemplatePage(request, pagename))
 
 
--- a/MoinMoin/security/autoadmin.py	Sat Jun 27 13:07:36 2009 +0200
+++ b/MoinMoin/security/autoadmin.py	Sat Jun 27 13:11:35 2009 +0200
@@ -73,11 +73,11 @@
             username = request.user.name
             pagename = request.page.page_name
             mainpage = pagename.split('/')[0]
-            if username == mainpage and u'AutoAdminGroup' in groups and username in groups[u'AutoAdminGroup']:
+            if username == mainpage and username in groups.get(u'AutoAdminGroup', []):
                 return True
             group_name = "%s/AdminGroup" % mainpage
-            if group_name in groups and username in groups[group_name] and \
-                    u'AutoAdminGroup' in groups and group_name in groups[u'AutoAdminGroup']:
+            if (username in groups.get(group_name, []) and
+                group_name in groups.get(u'AutoAdminGroup', [])):
                 return True
         except AttributeError:
             pass # when we get called from xmlrpc, there is no request.page
--- a/MoinMoin/security/textcha.py	Sat Jun 27 13:07:36 2009 +0200
+++ b/MoinMoin/security/textcha.py	Sat Jun 27 13:11:35 2009 +0200
@@ -50,7 +50,7 @@
         cfg = request.cfg
         user = request.user
         disabled_group = cfg.textchas_disabled_group
-        if disabled_group and user.name and disabled_group in groups and user.name in groups[disabled_group]:
+        if disabled_group and user.name and user.name in groups.get(disabled_group, []):
             return None
         textchas = cfg.textchas
         if textchas:
--- a/MoinMoin/userprefs/oidserv.py	Sat Jun 27 13:07:36 2009 +0200
+++ b/MoinMoin/userprefs/oidserv.py	Sat Jun 27 13:11:35 2009 +0200
@@ -29,8 +29,7 @@
         groups = self.request.groups
         openid_group_name = self.request.cfg.openid_server_restricted_users_group
 
-        if openid_group_name and \
-            not (openid_group_name in groups and self.request.user.name in groups[openid_group_name]):
+        if openid_group_name and self.request.user.name not in groups.get(openid_group_name, []):
                 return False
 
         return True