Commit 1f630eaa authored by Vincent Pelletier's avatar Vincent Pelletier

Move selection checksum computation next to its verification.

Allows getting current selection's MD5 even outside ListBox's renderer.

try 2: Now without NameError
parent c0332736
master allow_login_change allow_login_change_differentiate_id_and_login allow_login_change_wip arnau arnau-kns arnau-kns-without-property-mapping arnau-merge arnau-poc authentication_policy_fixes auto_extend_select_list autoflake backup_erp5_workflow bk_erp5ish_actions_tool bk_sqlcatalog bt_owner cache catalog_fulltext catalog_fulltext_old cedric cedriclen cedriclen-eos cherry-pick-4a8e045d cherry-pick-bca64206 cleanJSByJSLint clean_up_upgrader compact_title_no_reference credential_update_action datetimefield douglas_forum dream_distributor eos-dev erp5-component erp5-data-notebook erp5-forum erp5-preference erp5-release erp5-slapos-upgrade erp5-vifib erp5-vifib-cleanup erp5_calendar erp5_free_subscription erp5_workflow fix_system_processes_ownership floatArrayTest for_testrunner_1 for_testrunner_2 formbox gabriel gabriel-fix-rounding-in-accounting-generation gabriel-fix-rounding-in-accounting-generation2 gadget-json-value http_cache_fix import_fixes import_fixes_complete improve_default_caching_policy_manager isDeletable item_tracking_graph_editor jerome-bt-reference-doc jerome-test jerome_events jerome_graph_editor_renderjs jerome_new_style_solve_divergence jerome_promise_in_tests jerome_user_preference_time_zone jio jm/form-action-guard joblib-activity jupyter_egg_tests jupyter_import_dot_fix jupyter_import_dot_quickfix jupyter_kernel_fixes jupyter_reference_warning jupyter_restricted kns lignan lingnan listbox-generator mame-bt5-cleanup mame-erp5_project-cleanup mame-naming-convention mame-naming-convention-list_method mame-test-stock-indexation mame-work master-erp5-test-result-scalability master-erp5-test-result-scalability-rebase master-test-fix-additionalbt5path master_calendar_wip_patches master_calendar_wip_patches_extend_security master_no_guard_on_workflow_transition master_no_guard_on_workflow_transition_plus_calendar_wip_patchs merge_xhtml_jquery mmariani-inventory mrp new-render-presentation nexedi-erp5-jp no_reindex_data_stream officejs pere portal_callables portal_solver_process_security_configuration presentation rebased_mrp reindex_calendar_after_change_calendar_exception removed_portal_skin_redundancy romain-fulltext scalability-master2 scalability-master2-rebase scalability-rebase shop-box shop-box-rebased sms_more_than_140_characters strict_catalog syncml test_page testnode_software_link timezones tristan tristan-merge tristan-performance view-aggregated-amounts vivekpab_erp5webrenderjs_layoutconfig vivekpab_jabberclient vivekpab_renderjs_interfaces wenjie wenjie_branch xiaowu_newui yryr yryr-components-cp yryr-inventory-cache yryr-test yryr-with-components erp5.util-0.4.46 erp5.util-0.4.44 erp5.util-0.4.43 erp5.util-0.4.41 erp5.util-0.4.40 erp5.util-0.4.37
No related merge requests found
...@@ -50,7 +50,6 @@ from Products.ERP5Type.Globals import InitializeClass, get_request ...@@ -50,7 +50,6 @@ from Products.ERP5Type.Globals import InitializeClass, get_request
from Products.PythonScripts.Utility import allow_class from Products.PythonScripts.Utility import allow_class
from Products.PageTemplates.PageTemplateFile import PageTemplateFile from Products.PageTemplates.PageTemplateFile import PageTemplateFile
from warnings import warn from warnings import warn
from hashlib import md5
import cgi import cgi
DEFAULT_LISTBOX_DISPLAY_STYLE = 'table' DEFAULT_LISTBOX_DISPLAY_STYLE = 'table'
...@@ -2560,20 +2559,14 @@ class ListBoxHTMLRenderer(ListBoxRenderer): ...@@ -2560,20 +2559,14 @@ class ListBoxHTMLRenderer(ListBoxRenderer):
"""Generate a MD5 checksum against checked uids. This is used to confirm """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. that selected values do not change between a display of a dialog and an execution.
FIXME: this should only use getCheckedUidList, but Folder_deleteObjectList does not use FIXME: SelectionTool.getSelectionChecksum's uid_list parameter is
the feature that checked uids are used when no list method is specified. deprecated, but Folder_deleteObjectList does not use the feature that
checked uids are used when no list method is specified.
""" """
checked_uid_list = self.request.get('uids') return self.getSelectionTool().getSelectionChecksum(
if checked_uid_list is None: self.getSelectionName(),
checked_uid_list = self.getCheckedUidList() uid_list=self.request.get('uids'),
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): def getPhysicalRoot(self):
"""Return the physical root (an Application object). This method is required for """Return the physical root (an Application object). This method is required for
......
...@@ -1170,13 +1170,26 @@ class SelectionTool( BaseTool, SimpleItem ): ...@@ -1170,13 +1170,26 @@ class SelectionTool( BaseTool, SimpleItem ):
""" """
We want to be sure that the selection did not change 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, # XXX To avoid the difference of the string representations of int and long,
# convert each element to a string. # convert each element to a string.
object_uid_list = [str(x) for x in object_uid_list] return md5(str(sorted(str(uid) for uid in uid_list))).hexdigest()
object_uid_list.sort()
new_md5_string = md5(str(object_uid_list)).hexdigest()
return md5_string != new_md5_string
# Related document searching # Related document searching
def viewSearchRelatedDocumentDialog(self, index, form_id, 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