Commit b6f629d0 authored by Nicolas Dumazet's avatar Nicolas Dumazet

resetDynamicDocumentsOnceAtTransactionBoundary, to somehow "group"

interactions/interactors calls to resetDynamicDocuments and only
ever do once a reset.
If used wisely, with clever enough tests (aka do not commit
like crazies after each setter call), this should allow tests
to run much faster.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@42857 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 280d8611
......@@ -31,6 +31,7 @@ from Products.ERP5Type.UnrestrictedMethod import UnrestrictedMethod
from zLOG import LOG, WARNING, PANIC
from Products.ERP5Type.interfaces import ITypeProvider, ITypesTool
from Products.ERP5Type.dynamic.portal_type_class import synchronizeDynamicModules
from Products.ERP5Type.TransactionalVariable import getTransactionalVariable
class ComposedObjectIds(object):
......@@ -249,11 +250,35 @@ class TypesTool(TypeProvider):
return res
security.declareProtected(Permissions.ModifyPortalContent,
'resetDynamicDocumentsOnceAtTransactionBoundary')
def resetDynamicDocumentsOnceAtTransactionBoundary(self):
"""
Schedule a single reset at the end of the transaction, only once.
The idea behind this is that a reset is (very) costly and that we want
to do it as little often as possible.
Moreover, doing it twice in a transaction is useless (but still twice
as costly).
And lastly, WorkflowMethods are not yet clever enough to allow this
possibility, as they schedule interactions depending on an instance path:
calling two times a setter on two different portal types during the
same transaction would call twice resetDynamicDocuments without this
TransactionalVariable check
"""
tv = getTransactionalVariable()
key = 'TypesTool.resetDynamicDocumentsOnceAtTransactionBoundary'
if key not in tv:
tv[key] = None
transaction.get().addBeforeCommitHook(self.resetDynamicDocuments)
security.declareProtected(Permissions.ModifyPortalContent,
'resetDynamicDocuments')
def resetDynamicDocuments(self):
"""Resets all dynamic documents: force reloading erp.* classes"""
"""Resets all dynamic documents: force reloading erp.* classes
WARNING: COSTLY! Please double-check that
resetDynamicDocumentsOnceAtTransactionBoundary can't be used instead.
"""
synchronizeDynamicModules(self, force=True)
security.declareProtected(Permissions.AddPortalContent,
......
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