Commit e477bfaa authored by Łukasz Nowak's avatar Łukasz Nowak

Cache heavy method.

parent e96ef577
...@@ -37,6 +37,7 @@ from Products.ERP5Type.Globals import InitializeClass ...@@ -37,6 +37,7 @@ from Products.ERP5Type.Globals import InitializeClass
from Products.ERP5Type.Tool.BaseTool import BaseTool from Products.ERP5Type.Tool.BaseTool import BaseTool
from Products.ERP5Type import Permissions from Products.ERP5Type import Permissions
from Products.ERP5Type.Cache import DEFAULT_CACHE_SCOPE from Products.ERP5Type.Cache import DEFAULT_CACHE_SCOPE
from Products.ERP5Type.Cache import CachingMethod
from lxml import etree from lxml import etree
import time import time
try: try:
...@@ -1111,15 +1112,21 @@ class SlapTool(BaseTool): ...@@ -1111,15 +1112,21 @@ class SlapTool(BaseTool):
else: else:
return l[0].getObject() return l[0].getObject()
def _getComputerDocument(self, computer_reference): def _getNonCachedComputerDocument(self, computer_reference):
"""
Get the validated computer with this reference.
"""
return self._getDocument( return self._getDocument(
portal_type='Computer', portal_type='Computer',
# XXX Hardcoded validation state # XXX Hardcoded validation state
validation_state="validated", validation_state="validated",
reference=computer_reference) reference=computer_reference).getRelativeUrl()
def _getComputerDocument(self, computer_reference):
"""
Get the validated computer with this reference.
"""
result = CachingMethod(self._getNonCachedComputerDocument,
id='_getComputerDocument',
cache_factory='slap_cache_factory')(computer_reference)
return self.getPortalObject().restrictedTraverse(result)
@UnrestrictedMethod @UnrestrictedMethod
def _getComputerUidByReference(self, computer_reference): def _getComputerUidByReference(self, computer_reference):
......
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