From 995ba680604d06bcaebc37d70a9118ada77a3696 Mon Sep 17 00:00:00 2001
From: Arnaud Fontaine <arnaud.fontaine@nexedi.com>
Date: Wed, 2 Mar 2011 11:52:41 +0000
Subject: [PATCH] For per-document accessors generation, catch ValueError
 exceptions when applying accessors from properties and only display a message
 in the logs.

This exception is raised within the property documents when a property
is invalid (invalid type, category name, reference...)


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@43887 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 product/ERP5Type/Core/PropertySheet.py | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/product/ERP5Type/Core/PropertySheet.py b/product/ERP5Type/Core/PropertySheet.py
index 41b2962472..100fcc945f 100644
--- a/product/ERP5Type/Core/PropertySheet.py
+++ b/product/ERP5Type/Core/PropertySheet.py
@@ -227,6 +227,11 @@ class PropertySheet(Folder):
         property_definition_list.append(property_definition)
 
     for property_definition in property_definition_list:
-      property_definition.applyOnAccessorHolder(accessor_holder,
-                                                expression_context,
-                                                portal)
+      try:
+        property_definition.applyOnAccessorHolder(accessor_holder,
+                                                  expression_context,
+                                                  portal)
+      except ValueError, e:
+        LOG("ERP5Type.Core.PropertySheet", INFO,
+            "Invalid property '%s' for Property Sheet '%s': %s" % \
+            (property_definition.getId(), self.getId(), str(e)))
-- 
2.30.9