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):
self._invoke_always = {}
def _aq_reset():
# using clear to prevent changing the reference
Base.aq_method_generated.clear()
Base.aq_portal_type.clear()
Base.aq_related_generated = 0
try:
from Products.ERP5Form.PreferenceTool import PreferenceTool
PreferenceTool.aq_preference_generated = False
except ImportError:
LOG('ERP5Type', LOG, "ERP5Form.PreferenceTool not found")
# 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()
warnings.warn("_aq_reset is deprecated in favor of "\
"portal_types.resetDynamicDocumentsOnceAtTransactionBoundary, "\
"calling this method affects greatly performances",
DeprecationWarning, stacklevel=2)
# Callers expect to re-generates accessors right now, so call
# resetDynamicDocuments to maintain backward-compatibility
from Products.ERP5.ERP5Site import getSite
getSite().portal_types.resetDynamicDocuments()
global method_registration_cache
method_registration_cache = {}
......
......@@ -480,7 +480,6 @@ def synchronizeDynamicModules(context, force=False):
LOG('ERP5Site', INFO, 'Transition successful, please update your'
' business templates')
LOG("ERP5Type.dynamic", 0, "Resetting dynamic classes")
for class_name, klass in inspect.getmembers(erp5.portal_type,
inspect.isclass):
......@@ -493,6 +492,8 @@ def synchronizeDynamicModules(context, force=False):
finally:
Base.aq_method_lock.release()
# Necessary because accessors are wrapped in WorkflowMethod by
# _aq_dynamic (performed in createAccessorHolder)
_aq_reset()
# Some method generations are based on portal methods, and portal
# methods cache results. So it is safer to invalidate the cache.
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