Commit c803a430 authored by Tatuya Kamada's avatar Tatuya Kamada

Add a method to update the persistent id_dict from portal_ids table.

This method is intended to use when we are disabled 'Store in the ZODB'
or set a big number as the 'Store interval', but at the same time we need to
update the persistent dict from the fresh portal_ids table at a certain point.

This method needs a unit test.
parent ed8dac90
master allow_login_change allow_login_change_differentiate_id_and_login allow_login_change_wip arnau arnau-fec arnau-kns arnau-kns-without-property-mapping arnau-merge arnau-poc arnau-real-time-inventory-accounting auto_extend_select_list autoflake backup_erp5_workflow bk_erp5ish_actions_tool bk_sqlcatalog boc-interaction-drop bt5_config cache callable-jupyter-storage catalog_filter catalog_fulltext catalog_fulltext_old cedric cedriclen cedriclen-eos cherry-pick-243c2f03 cherry-pick-4a8e045d cleanJSByJSLint clean_up_upgrader cleanup/zsql_method_arguments_backslash_n cleanup_acquisition_base_category compact_title_no_reference credential_update_action datetime_key_change_date_delimiter_dash_timezone datetimefield delivery_item_barcode douglas_forum dream_distributor dsn-phase3 eos-dev erp5-component erp5-data-notebook erp5-forum erp5-preference erp5-release erp5-slapos-upgrade erp5-util-testing erp5-vifib erp5-vifib-cleanup erp5_calendar erp5_catalog erp5_catalog_final erp5_free_subscription erp5_workflow erp5js_searcheditor_date_bug erp5js_searcheditor_date_bug2 erp5jslistbox erp5testnode_max_timeout experiment/coding_style_test_suite feat/accounting_stop_using_getObject feat/accounting_translate_gap feat/delete_on_category_workflow feat/longer_language_cookie feat/new_test_template_suggest_bad_coding_practice feat/olapy feat/pdm_content_translation feat/publication_workflow_transitions feat/remove_owner_role_permissions_on_document_workflow feat/test_inventory_api_domain_selection feat/trade_shipment_report feat/wendelin-py-data feature/accounting-reports-stats feature/hal-actions-support feature/hal-support-update feature/jio-accounting-reports feature/jio-selection-actions feature/json-allows-all-jio-actions feature/renderjs-matrixbox feature/renderjs-ui-no-header feature/rjs-listbox-stats feature/rjs-print-action fix/bank_reconciliation_with_internal_transaction fix/consistency_check_alarm fix/edit_activity_pending_error fix/full_text_script_conflict fix/generate_source_reference_after_ptg_clone fix/login_validate_check_consistency fix/multiple_small_fixes_to_zodb_history_tab fix/notification_message_references fix_hateoas_localizer fix_system_processes_ownership for_testrunner_1 for_testrunner_2 for_testrunner_3 gabriel gabriel-fix-rounding-in-accounting-generation gabriel-fix-rounding-in-accounting-generation2 gadget-json-value heads/fix/notification_tool_unauthorized hotfix/accounting-test-timeout hotfix/callable_tool hotfix/field-keeps-request hotfix/jio_view hotfix/pdm-test hotfix/rjs-editability hotfix/rjs-form-less-invasive hotfix/rjs-formfields-padding hotfix/rjs-listbox-mutex hotfix/tests-cleanup http_cache_fix improve_default_caching_policy_manager initsite interaction-drop isDeletable item_tracking_graph_editor jerome-bt-reference-doc jerome_graph_editor_renderjs jerome_new_style_solve_divergence jerome_user_preference_time_zone jio jm/form-action-guard joblib-activity kns kns-kr lignan lingnan listbox-generator listbox_url macros_fix mame-bt5-cleanup mame-erp5_project-cleanup mame-naming-convention mame-naming-convention-list_method mame-test-stock-indexation mame-work maste_copy 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 monitoring monitoring-graph mrp new-render-presentation nexedi-erp5-jp no_longer_simulated_state officejs officejs_clean officejs_zip ojs_wip pere portal_callables portal_solver_process_security_configuration presentation rebased_mrp refactor/base_edit refactor/renderjs reindex_calendar_after_change_calendar_exception reverse_logistics revert-38554dbe rewrite_test_21_AcquiredPortalType romain-fulltext scalability-master2 scalability-master2-rebase scalability-rebase scalability-roque scalability-roque-2 scalability-roque-runner shop-box simulation sms_more_than_140_characters strict_catalog sws_fix syncml taskdistribution-xmlrpc-binary test_page testnode_software_link timezones tmp/getInstalledBusinessTemplate_never_installed_bt tristan tristan-merge tristan-performance upgradeSite view-aggregated-amounts vivekpab_erp5webrenderjs_layoutconfig vivekpab_jabberclient vivekpab_renderjs_interfaces wenjie wenjie_branch yryr yryr-components-cp yryr-inventory-cache yryr-test yryr-with-components yusei yusei_erp5js_listbox_link yusei_functional_test_firefox yusei_service_worker yusei_testnode test-ui test-rjsacc test-rjs renderjs-test erp5.util-0.4.49 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
......@@ -282,3 +282,27 @@ class SQLNonContinuousIncreasingIdGenerator(IdGenerator):
portal.IdTool_zDropTable()
portal.IdTool_zCreateEmptyTable()
self._updateSqlTable()
security.declareProtected(Permissions.ModifyPortalContent,
'updateLastMaxIdDictFromTable')
def updateLastMaxIdDictFromTable(self):
"""
Update the Persistent id_dict from portal_ids table.
Warning: IdToool_zGetValueList ZSQL method retrieve all the records of
portal_ids table. So this method neither does not scale well if you have
millions id_group.
"""
portal = self.getPortalObject()
get_value_list = portal.IdTool_zGetValueList
new_id_dict = dict()
for line in get_value_list().dictionaries():
id_group = line['id_group']
last_id = line['last_id']
if isinstance(last_id, int) or isinstance(last_id, long):
new_id_dict[id_group] = ScalarMaxConflictResolver(last_id)
else:
raise TypeError, 'the value in the dictionary given is not a number'
if self.last_max_id_dict is None:
self.last_max_id_dict = PersistentMapping()
self.last_max_id_dict.update(new_id_dict)
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