changeset 37:ad1d433589e4

moved test for PIL to a better place
author Reimar Bauer <rb.proj AT googlemail DOT com>
date Sat, 24 May 2008 12:08:08 +0200
parents 3f042c1e2509
children e6bd98eea9f5
files data/plugin/action/arnica_slides.py data/plugin/parser/text_x_arnica.py
diffstat 2 files changed, 15 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/data/plugin/action/arnica_slides.py	Sat May 24 11:45:53 2008 +0200
+++ b/data/plugin/action/arnica_slides.py	Sat May 24 12:08:08 2008 +0200
@@ -346,12 +346,6 @@
         arena_dir = caching.get_arena_dir(request, page, 'item')
         msg = None
 
-        if not Image:
-            msg = _('The action %(action)s needs python imaging library (PIL) installed' % {'action': action_name})
-            request.theme.add_msg(msg, "error")
-            self.page.send_page()
-            return
-
         request.formatter = Formatter(request)
         attachment_path = AttachFile.getAttachDir(request, pagename)
         command = request.form.get('do', ['none'])[0]
@@ -490,5 +484,12 @@
 
 def execute(pagename, request):
     """ Main dispatcher for the arnica_slides action. """
+    _ = request.getText
+    if not Image:
+        msg = _('The action %(action)s needs python imaging library (PIL) installed' % {'action': action_name})
+        request.theme.add_msg(msg, "error")
+        Page(request, pagename).send_page()
+        return
+
     return arnica_slides(request, pagename).render()
 
--- a/data/plugin/parser/text_x_arnica.py	Sat May 24 11:45:53 2008 +0200
+++ b/data/plugin/parser/text_x_arnica.py	Sat May 24 12:08:08 2008 +0200
@@ -102,6 +102,8 @@
 except ImportError:
     Image = None
 
+parser_name = __name__.split('.')[-1]
+
 # ToDo may be move to wikiutil
 def get_exif_info(file_name):
     """ gets exif info from image file
@@ -558,6 +560,12 @@
         @param thumbnail: name of thumbnail file
         @param image_type: filetype of image
         """
+        _ = self.request.getText
+        if not Image:
+            msg = _('The parser %(parser)s needs python imaging library (PIL) installed' % {'parser': parser_name})
+            self.request.write(msg)
+            return
+    
         path = AttachFile.getAttachDir(self.request, self.pagename, create=1)
         imagef = os.path.join(path, image)