Commit 98a7b308 authored by Vincent Pelletier's avatar Vincent Pelletier

Revert "Move selection checksum computation next to its verification."

This reverts commit 1f630eaa.
One bug left, which uncovered shortcommings in 4 tests:
- 3 tests duplicate checksum computation code
- 1 test relies on previous tests not leaving garbage
parent ddfb0671
......@@ -50,6 +50,7 @@ from Products.ERP5Type.Globals import InitializeClass, get_request
from Products.PythonScripts.Utility import allow_class
from Products.PageTemplates.PageTemplateFile import PageTemplateFile
from warnings import warn
from hashlib import md5
import cgi
DEFAULT_LISTBOX_DISPLAY_STYLE = 'table'
......@@ -2559,14 +2560,20 @@ class ListBoxHTMLRenderer(ListBoxRenderer):
"""Generate a MD5 checksum against checked uids. This is used to confirm
that selected values do not change between a display of a dialog and an execution.
FIXME: SelectionTool.getSelectionChecksum's uid_list parameter is
deprecated, but Folder_deleteObjectList does not use the feature that
checked uids are used when no list method is specified.
FIXME: this should only use getCheckedUidList, but Folder_deleteObjectList does not use
the feature that checked uids are used when no list method is specified.
"""
return self.getSelectionTool().getSelectionChecksum(
self.getSelectionName(),
uid_list=self.request.get('uids'),
)
checked_uid_list = self.request.get('uids')
if checked_uid_list is None:
checked_uid_list = self.getCheckedUidList()
if checked_uid_list is not None:
checked_uid_list = [str(uid) for uid in checked_uid_list]
checked_uid_list.sort()
md5_string = md5(str(checked_uid_list)).hexdigest()
else:
md5_string = None
return md5_string
def getPhysicalRoot(self):
"""Return the physical root (an Application object). This method is required for
......
......@@ -1170,26 +1170,13 @@ class SelectionTool( BaseTool, SimpleItem ):
"""
We want to be sure that the selection did not change
"""
return object_uid_list != self._getUIDListChecksum(object_uid_list)
security.declareProtected(ERP5Permissions.View, 'getSelectionChecksum')
def getSelectionChecksum(self, selection_name, uid_list=None):
"""Generate an MD5 checksum against checked uids. This is used to confirm
that selected values do not change between a display of a dialog and an
execution.
uid_list (deprecated)
For backward compatibility with code not updating selected uids.
"""
if uid_list is None:
uid_list = self.getSelectionCheckedUidsFor(selection_name)
return self._getUIDListChecksum(uid_list)
def _getUIDListChecksum(self, uid_list):
if uid_list is None:
return None
# XXX To avoid the difference of the string representations of int and long,
# convert each element to a string.
return md5(str(sorted(str(uid) for uid in uid_list))).hexdigest()
object_uid_list = [str(x) for x in object_uid_list]
object_uid_list.sort()
new_md5_string = md5(str(object_uid_list)).hexdigest()
return md5_string != new_md5_string
# Related document searching
def viewSearchRelatedDocumentDialog(self, index, form_id,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment