From 98cd0d3022958b92193c162eef8fad43b51775d4 Mon Sep 17 00:00:00 2001 From: Yoshinori Okuji <yo@nexedi.com> Date: Tue, 24 May 2005 12:26:52 +0000 Subject: [PATCH] Convert each uid to a string for generating a checksum, to avoid different representations of long and int. git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@3068 20353a03-c40f-0410-a6d1-a30d3c3de9de --- product/ERP5Form/ListBox.py | 12 +++++------- product/ERP5Form/SelectionTool.py | 17 ++++++----------- 2 files changed, 11 insertions(+), 18 deletions(-) diff --git a/product/ERP5Form/ListBox.py b/product/ERP5Form/ListBox.py index ef17831f25..f3b20a3b42 100755 --- a/product/ERP5Form/ListBox.py +++ b/product/ERP5Form/ListBox.py @@ -1059,13 +1059,11 @@ class ListBoxWidget(Widget.Widget): # ############################################################### - object_uid_list = map(lambda x: getattr(x, 'uid', None), object_list) - #LOG('ListBox.render, object_uid_list:',0,object_uid_list) - sorted_object_uid_list = copy(object_uid_list) - sorted_object_uid_list.sort() - md5_string = md5.new(str(sorted_object_uid_list)).hexdigest() - #md5_string = md5.new(str(object_uid_list)).digest() - + # XXX To avoid the difference of the string representations of int and long, + # convert each element to a string. + object_uid_list = [str(getattr(x, 'uid', None)) for x in object_list] + object_uid_list.sort() + md5_string = md5.new(str(object_uid_list)).hexdigest() ############################################################### # diff --git a/product/ERP5Form/SelectionTool.py b/product/ERP5Form/SelectionTool.py index f7438022d5..d468252cc7 100755 --- a/product/ERP5Form/SelectionTool.py +++ b/product/ERP5Form/SelectionTool.py @@ -756,17 +756,12 @@ class SelectionTool( UniqueObject, SimpleItem ): """ We want to be sure that the selection did not change """ - #LOG('selectionHasChanged, md5_string',0,md5_string) - #LOG('selectionHasChanged, object_uid_list',0,object_uid_list) - sorted_object_uid_list = copy(object_uid_list) - sorted_object_uid_list.sort() - new_md5_string = md5.new(str(sorted_object_uid_list)).hexdigest() - #LOG('selectionHasChanged, new_md5_string',0,new_md5_string) - if md5_string != new_md5_string: - #LOG('selectionHasChanged, return...',0,'True') - return True - #LOG('selectionHasChanged, return...',0,'False') - return False + # XXX To avoid the difference of the string representations of int and long, + # convert each element to a string. + object_uid_list = [str(x) for x in object_uid_list] + object_uid_list.sort() + new_md5_string = md5.new(str(object_uid_list)).hexdigest() + return md5_string != new_md5_string security.declareProtected(ERP5Permissions.View, 'getPickle') def getPickle(self,**kw): -- 2.30.9