changeset 3629:bf72cc397f76

fix some ImportError handlers: SpellCheck is builtin. Don't hide import errors in wikiserverconfig.
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Tue, 20 May 2008 19:33:22 +0200
parents 7f1e4cac0f89
children a53307694ba3
files MoinMoin/PageEditor.py MoinMoin/PageGraphicalEditor.py MoinMoin/script/server/standalone.py
diffstat 3 files changed, 13 insertions(+), 22 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/PageEditor.py	Tue May 20 18:35:44 2008 +0200
+++ b/MoinMoin/PageEditor.py	Tue May 20 19:33:22 2008 +0200
@@ -147,10 +147,7 @@
         @keyword comment: comment field (when preview is true)
         """
         from MoinMoin import i18n
-        try:
-            from MoinMoin.action import SpellCheck
-        except ImportError:
-            SpellCheck = None
+        from MoinMoin.action import SpellCheck
         request = self.request
         form = request.form
         _ = self._
@@ -358,9 +355,7 @@
             request.write(unicode(html.INPUT(type="hidden", name="backto", value=backto)))
 
         # button bar
-        button_spellcheck = (SpellCheck and
-            '<input class="button" type="submit" name="button_spellcheck" value="%s" onClick="flgChange = false;">'
-                % _('Check Spelling')) or ''
+        button_spellcheck = '<input class="button" type="submit" name="button_spellcheck" value="%s" onClick="flgChange = false;">' % _('Check Spelling')
 
         save_button_text = _('Save Changes')
         cancel_button_text = _('Cancel')
@@ -480,9 +475,7 @@
 
         badwords_re = None
         if preview is not None:
-            if SpellCheck and (
-                    'button_spellcheck' in form or
-                    'button_newwords' in form):
+            if 'button_spellcheck' in form or 'button_newwords' in form:
                 badwords, badwords_re, msg = SpellCheck.checkSpelling(self, request, own_form=0)
                 request.write("<p>%s</p>" % msg)
         request.write('</fieldset>')
--- a/MoinMoin/PageGraphicalEditor.py	Tue May 20 18:35:44 2008 +0200
+++ b/MoinMoin/PageGraphicalEditor.py	Tue May 20 19:33:22 2008 +0200
@@ -46,10 +46,7 @@
         @keyword comment: comment field (when preview is true)
         """
         from MoinMoin import i18n
-        try:
-            from MoinMoin.action import SpellCheck
-        except ImportError:
-            SpellCheck = None
+        from MoinMoin.action import SpellCheck
 
         request = self.request
         form = request.form
@@ -253,9 +250,7 @@
             request.write(unicode(html.INPUT(type="hidden", name="backto", value=backto)))
 
         # button bar
-        button_spellcheck = (SpellCheck and
-            '<input class="button" type="submit" name="button_spellcheck" value="%s">'
-                % _('Check Spelling')) or ''
+        button_spellcheck = '<input class="button" type="submit" name="button_spellcheck" value="%s">' % _('Check Spelling')
 
         save_button_text = _('Save Changes')
         cancel_button_text = _('Cancel')
@@ -397,9 +392,7 @@
 
         badwords_re = None
         if preview is not None:
-            if SpellCheck and (
-                    'button_spellcheck' in form or
-                    'button_newwords' in form):
+            if 'button_spellcheck' in form or 'button_newwords' in form:
                 badwords, badwords_re, msg = SpellCheck.checkSpelling(self, request, own_form=0)
                 request.write("<p>%s</p>" % msg)
         request.write('</fieldset>')
--- a/MoinMoin/script/server/standalone.py	Tue May 20 18:35:44 2008 +0200
+++ b/MoinMoin/script/server/standalone.py	Tue May 20 19:33:22 2008 +0200
@@ -98,8 +98,13 @@
                 if self.options.config_dir:
                     sys.path.insert(0, self.options.config_dir)
                 from wikiserverconfig import Config
-            except ImportError:
-                Config = DefaultConfig
+            except ImportError, err:
+                if 'Config' in str(err):
+                    # we are unable to import Config
+                    Config = DefaultConfig
+                else:
+                    # some other import went wrong
+                    raise
 
             if self.options.docs:
                 Config.docs = self.options.docs