Commit 3d5096a5 authored by Arnaud Fontaine's avatar Arnaud Fontaine

Implement reset performed only once at transaction boundary (similarly to Portal Type classes).

parent 8a3acd8e
......@@ -50,7 +50,7 @@
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>state_change[\'object\'].reset()\n
<value> <string>state_change[\'object\'].getPortalObject().portal_components.resetOnceAtTransactionBoundary()\n
</string> </value>
</item>
<item>
......
2012-02-07 arnaud.fontaine
* Use resetOnceAtTransactionBoundary when a Component has been modified.
2012-02-02 arnaud.fontaine
* Perform revalidate automatically rather than requiring a manual action.
......
40999
\ No newline at end of file
41000
\ No newline at end of file
......@@ -27,9 +27,12 @@
#
##############################################################################
import transaction
from AccessControl import ClassSecurityInfo
from Products.ERP5Type.Tool.BaseTool import BaseTool
from Products.ERP5Type import Permissions
from Products.ERP5Type.TransactionalVariable import getTransactionalVariable
from zLOG import LOG, INFO, WARNING
......@@ -46,7 +49,7 @@ class ComponentTool(BaseTool):
security = ClassSecurityInfo()
security.declareObjectProtected(Permissions.AccessContentsInformation)
security.declareProtected(Permissions.ManagePortal, 'reset')
security.declareProtected(Permissions.ModifyPortalContent, 'reset')
def reset(self, is_sync=False):
"""
XXX-arnau: global reset
......@@ -82,13 +85,27 @@ class ComponentTool(BaseTool):
type_tool.resetDynamicDocumentsOnceAtTransactionBoundary()
security.declareProtected(Permissions.ModifyPortalContent,
'resetOnceAtTransactionBoundary')
def resetOnceAtTransactionBoundary(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).
"""
tv = getTransactionalVariable()
key = 'ComponentTool.resetOnceAtTransactionBoundary'
if key not in tv:
tv[key] = None
transaction.get().addBeforeCommitHook(self.reset)
security.declareProtected(Permissions.ManagePortal,
'createAllComponentFromFilesystem')
def createAllComponentFromFilesystem(self, erase_existing=False,
REQUEST=None):
"""
XXX-arnau: only Extensions for now
XXX-arnau: only bt5 Extensions and Documents for now
"""
portal = self.getPortalObject()
......
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