changeset 2305:5c75990712ca

make sure userprefs plugins that say not allowed() will never be invoked
author Johannes Berg <johannes AT sipsolutions DOT net>
date Wed, 11 Jul 2007 11:39:59 +0200
parents 8eb96bfafef9
children 5cf429e40f18
files MoinMoin/action/userprefs.py
diffstat 1 files changed, 11 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/action/userprefs.py	Wed Jul 11 11:39:18 2007 +0200
+++ b/MoinMoin/action/userprefs.py	Wed Jul 11 11:39:59 2007 +0200
@@ -60,12 +60,19 @@
         msg = None
 
     sub = request.form.get('sub', [''])[0]
-    try:
-        cls = wikiutil.importPlugin(request.cfg, 'userprefs', sub, 'Settings')
-    except wikiutil.PluginMissingError:
+    cls = None
+    if sub:
+        try:
+            cls = wikiutil.importPlugin(request.cfg, 'userprefs', sub, 'Settings')
+        except wikiutil.PluginMissingError:
+            # cls is already None
+            pass
+
+    obj = cls and cls(request)
+
+    if not obj or not obj.allowed():
         return _create_prefs_page(request), None, msg
 
-    obj = cls(request)
     return obj.create_form(), obj.title, msg