Commit 680d8675 authored by Arnaud Fontaine's avatar Arnaud Fontaine

_aq_reset calls resetRegisteredWorkflowMethod without actually triggering

accessors regeneration, thus replace it by a resetDynamicDocuments().
resetDynamicDocumentsOnceAtTransactionBoundary should be called
instead when possible to avoid excessive re-generation of accessors.



git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@43009 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 41ed1033
...@@ -290,22 +290,15 @@ class WorkflowMethod(Method): ...@@ -290,22 +290,15 @@ class WorkflowMethod(Method):
self._invoke_always = {} self._invoke_always = {}
def _aq_reset(): def _aq_reset():
# using clear to prevent changing the reference warnings.warn("_aq_reset is deprecated in favor of "\
Base.aq_method_generated.clear() "portal_types.resetDynamicDocumentsOnceAtTransactionBoundary, "\
Base.aq_portal_type.clear() "calling this method affects greatly performances",
Base.aq_related_generated = 0 DeprecationWarning, stacklevel=2)
try:
from Products.ERP5Form.PreferenceTool import PreferenceTool # Callers expect to re-generates accessors right now, so call
PreferenceTool.aq_preference_generated = False # resetDynamicDocuments to maintain backward-compatibility
except ImportError: from Products.ERP5.ERP5Site import getSite
LOG('ERP5Type', LOG, "ERP5Form.PreferenceTool not found") getSite().portal_types.resetDynamicDocuments()
# Some method generations are based on portal methods, and portal methods cache results.
# So it is safer to invalidate the cache.
clearCache()
# Reset workflow methods so that they no longer invoke workflows
resetRegisteredWorkflowMethod()
global method_registration_cache global method_registration_cache
method_registration_cache = {} method_registration_cache = {}
......
...@@ -480,7 +480,6 @@ def synchronizeDynamicModules(context, force=False): ...@@ -480,7 +480,6 @@ def synchronizeDynamicModules(context, force=False):
LOG('ERP5Site', INFO, 'Transition successful, please update your' LOG('ERP5Site', INFO, 'Transition successful, please update your'
' business templates') ' business templates')
LOG("ERP5Type.dynamic", 0, "Resetting dynamic classes") LOG("ERP5Type.dynamic", 0, "Resetting dynamic classes")
for class_name, klass in inspect.getmembers(erp5.portal_type, for class_name, klass in inspect.getmembers(erp5.portal_type,
inspect.isclass): inspect.isclass):
...@@ -493,6 +492,8 @@ def synchronizeDynamicModules(context, force=False): ...@@ -493,6 +492,8 @@ def synchronizeDynamicModules(context, force=False):
finally: finally:
Base.aq_method_lock.release() Base.aq_method_lock.release()
# Necessary because accessors are wrapped in WorkflowMethod by # Some method generations are based on portal methods, and portal
# _aq_dynamic (performed in createAccessorHolder) # methods cache results. So it is safer to invalidate the cache.
_aq_reset() cache_tool = getattr(context, 'portal_caches', None)
if cache_tool is not None:
cache_tool.clearCache()
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