From 107c6c8a2b41f57d50d25357bf72061e09c5b0c5 Mon Sep 17 00:00:00 2001 From: Romain Courteaud <romain@nexedi.com> Date: Fri, 18 Nov 2005 13:52:43 +0000 Subject: [PATCH] Catch the error raised by portal_catalog.getObject when the uid is a string. git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@4356 20353a03-c40f-0410-a6d1-a30d3c3de9de --- product/ERP5Form/MultiRelationField.py | 6 +++++- product/ERP5Form/RelationField.py | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/product/ERP5Form/MultiRelationField.py b/product/ERP5Form/MultiRelationField.py index 4b46a7263a..73c8e0bb39 100755 --- a/product/ERP5Form/MultiRelationField.py +++ b/product/ERP5Form/MultiRelationField.py @@ -411,7 +411,11 @@ class MultiRelationStringFieldValidator(Validator.LinesValidator, RelationField if relation_uid not in (None, ''): # A value has been defined by the user in popup menu if type(relation_uid) in (type([]), type(())): relation_uid = relation_uid[0] - related_object = portal_catalog.getObject(relation_uid) + try: + related_object = portal_catalog.getObject(relation_uid) + except ValueError: + # Catch the exception raised when the uid is a string + related_object = None if related_object is not None: display_text = str(related_object.getProperty(catalog_index)) else: diff --git a/product/ERP5Form/RelationField.py b/product/ERP5Form/RelationField.py index 3f38b17212..a6475d40f4 100755 --- a/product/ERP5Form/RelationField.py +++ b/product/ERP5Form/RelationField.py @@ -350,7 +350,11 @@ class RelationStringFieldValidator(Validator.StringValidator): else: relation_uid = relation_uid[0] - related_object = portal_catalog.getObject(relation_uid) + try: + related_object = portal_catalog.getObject(relation_uid) + except ValueError: + # Catch the error raised when the uid is a string + related_object = None if related_object is not None: display_text = str(related_object.getProperty(catalog_index)) else: -- 2.30.9