commit-gnue
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[gnue] r9202 - trunk/gnue-forms/src/input/displayHandlers


From: jamest
Subject: [gnue] r9202 - trunk/gnue-forms/src/input/displayHandlers
Date: Thu, 4 Jan 2007 14:36:53 -0600 (CST)

Author: jamest
Date: 2007-01-04 14:36:51 -0600 (Thu, 04 Jan 2007)
New Revision: 9202

Modified:
   trunk/gnue-forms/src/input/displayHandlers/Image.py
   trunk/gnue-forms/src/input/displayHandlers/__init__.py
Log:
don't import PIL unless the form contains an <image>
abort if form requires an <image> and PIL is not available


Modified: trunk/gnue-forms/src/input/displayHandlers/Image.py
===================================================================
--- trunk/gnue-forms/src/input/displayHandlers/Image.py 2007-01-04 15:56:26 UTC 
(rev 9201)
+++ trunk/gnue-forms/src/input/displayHandlers/Image.py 2007-01-04 20:36:51 UTC 
(rev 9202)
@@ -29,13 +29,24 @@
 
 from gnue.common.utils.FileUtils import openResource
 from gnue.forms.input.displayHandlers.Cursor import BaseCursor
+from gnue.common.apps import errors
 import cStringIO
+
+class NeedsPilForImages(errors.AdminError):
+    """
+    Python Imaging (PIL) is required but not installed.
+    """
+    def __init__(self):
+        errors.AdminError.__init__(self, u_(
+            "Form contains a <image> but python image support not installed") )
+
 try:
   from PIL import Image as PILImage
 except ImportError:
   PILImage = None
-  print "Form contains a <image> but python image support not installed"
-  print "Install PIL from http://www.pythonware.com/products/pil/";
+  gDebug(0, "Form contains a <image> but python image support not installed")
+  gDebug(0, "Install PIL from http://www.pythonware.com/products/pil/";)
+  raise NeedsPilForImages()
 
 class Image(BaseCursor):
   """

Modified: trunk/gnue-forms/src/input/displayHandlers/__init__.py
===================================================================
--- trunk/gnue-forms/src/input/displayHandlers/__init__.py      2007-01-04 
15:56:26 UTC (rev 9201)
+++ trunk/gnue-forms/src/input/displayHandlers/__init__.py      2007-01-04 
20:36:51 UTC (rev 9202)
@@ -29,7 +29,6 @@
       "Component",
       "DateTime",
       "Dropdown",
-      "Image",
       "Listbox",
       "Numeric",
       "Password",
@@ -52,10 +51,14 @@
                        'listbox': Listbox,
                        'password':Password,
                        'number':  Numeric,
-                       'image' : Image
+                      'image': None,
                       }
   
   if entry._type == 'GFImage':
+    # Only import the Image handler if used in the form
+    if classConstructors['image'] is None:
+      from gnue.forms.input.displayHandlers.Image import Image
+      classConstructors['image'] = Image
     # Images don't need input masks so just return the image now
     # return Image(entry, eventHandler, subEventHandler)
     key = 'image'





reply via email to

[Prev in Thread] Current Thread [Next in Thread]