Author: jmorliaguet
Date: Sat May 20 11:55:52 2006
New Revision: 3170

Modified:
   cpsskins/branches/paris-sprint-2006/setup/manager.py
   cpsskins/branches/paris-sprint-2006/standard/filters/style/views.py

Log:

- log warnings when resolving URIs instead of raising exceptions



Modified: cpsskins/branches/paris-sprint-2006/setup/manager.py
==============================================================================
--- cpsskins/branches/paris-sprint-2006/setup/manager.py        (original)
+++ cpsskins/branches/paris-sprint-2006/setup/manager.py        Sat May 20 
11:55:52 2006
@@ -17,6 +17,7 @@
 """
 __docformat__ = "reStructuredText"
 
+import logging
 from copy import deepcopy
 
 from zope.app.container.interfaces import INameChooser
@@ -29,6 +30,8 @@
 from cpsskins.setup.utils import getContentType
 from cpsskins.utils import getThemeManager
 
+logger = logging.getLogger("cpsskins")
+
 class ResourceManager(object):
     """Resource manager utility.
     """
@@ -122,7 +125,8 @@
         if '@' in location:
             setting = self.lookup(uri, context)
             if setting is None:
-                raise ValueError("No such setting: %s" % uri)
+                logger.warning("No such setting: %s", uri)
+                return None
             resource = IResource(setting).getResource()
 
         elif ':' in location:
@@ -131,11 +135,13 @@
             try:
                 obj = getThemeManager(context).getElementById(resource_id)
             except KeyError:
-                raise KeyError("no such identifier: %s" % resource_id)
+                logger.warning("no such identifier: %s", resource_id)
+                return None
             obj_type = IType(obj).getTypeName()
             if type_name != obj_type:
-                raise TypeError("type mismatch: expected '%s' got '%s'." % \
-                                (obj_type, type_name))
+                logger.warning("type mismatch: expected '%s' got '%s'.",
+                               obj_type, type_name)
+                return None
             return obj
 
         else:

Modified: cpsskins/branches/paris-sprint-2006/standard/filters/style/views.py
==============================================================================
--- cpsskins/branches/paris-sprint-2006/standard/filters/style/views.py 
(original)
+++ cpsskins/branches/paris-sprint-2006/standard/filters/style/views.py Sat May 
20 11:55:52 2006
@@ -115,12 +115,14 @@
     def setFormData(self):
         data = self.data
         selector = data.get(u'selector')
+        if selector is None:
+            raise ValueError("The CSS selector is not set.")
         uri = data.get(u'uri')
+        if not uri:
+            raise ValueError("The style URI is not set.")
         resources = getUtility(IResourceManager)
         style = resources.resolve(uri, context=self.context)
 
-        if selector is None:
-            raise ValueError("The CSS selector is not set.")
 
         props = {}
         for name in self.getFieldNames():
-- 
http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins

Reply via email to