From c09b9991099c656543fe5f09d905b232992478c0 Mon Sep 17 00:00:00 2001
From: Yoshinori Okuji <yo@nexedi.com>
Date: Thu, 15 Dec 2005 23:37:43 +0000
Subject: [PATCH] The validator should catch ValueError. Also, if uid is not an
 integer, try to compare as strings.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@4672 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 product/ERP5Form/ListBox.py | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/product/ERP5Form/ListBox.py b/product/ERP5Form/ListBox.py
index 1ba0cacd08..9e2a66b15b 100755
--- a/product/ERP5Form/ListBox.py
+++ b/product/ERP5Form/ListBox.py
@@ -2090,7 +2090,7 @@ class ListBoxValidator(Validator.Validator):
               # because sometimes, we can be provided bad uids
               try :
                 o = here.portal_catalog.getObject(uid)
-              except KeyError, NotFound:
+              except (KeyError, NotFound, ValueError):
                 o = None
               if o is None:
                 # It is possible that this object is not catalogged yet. So
@@ -2100,9 +2100,14 @@ class ListBoxValidator(Validator.Validator):
                   list_method = getattr(here, list_method.method_name)
                   object_list = list_method(REQUEST=REQUEST,**params)
                 for object in object_list:
-                  if object.getUid() == int(uid):
-                    o = object
-                    break
+                  try:
+                    if object.getUid() == int(uid):
+                      o = object
+                      break
+                  except ValueError:
+                    if str(object.getUid()) == uid:
+                      o = object
+                      break
               for sql in editable_column_ids:
                 alias = '_'.join(sql.split('.'))
                 if '.' in sql:
-- 
2.30.9