Commit ad3ac5e2 authored by Romain Courteaud's avatar Romain Courteaud

Add a shared cache to speed up getComputerInformation

parent ff58e583
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Cache Factory" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_count</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>_mt_index</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
<item>
<key> <string>_tree</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent>
</value>
</item>
<item>
<key> <string>cache_duration</string> </key>
<value> <int>200</int> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>slap_cache_factory</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Cache Factory</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Slap Cache Factory</string> </value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="Length" module="BTrees.Length"/>
</pickle>
<pickle> <int>0</int> </pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="OOBTree" module="BTrees.OOBTree"/>
</pickle>
<pickle>
<none/>
</pickle>
</record>
<record id="4" aka="AAAAAAAAAAQ=">
<pickle>
<global name="OOBTree" module="BTrees.OOBTree"/>
</pickle>
<pickle>
<none/>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Distributed Ram Cache" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>categories</string> </key>
<value>
<tuple>
<string>specialise/portal_memcached/persistent_memcached_plugin</string>
</tuple>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>persistent_cache_plugin</string> </value>
</item>
<item>
<key> <string>int_index</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Distributed Ram Cache</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Persistent Distributed Ram Cache</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
391 392
\ No newline at end of file \ No newline at end of file
...@@ -68,6 +68,8 @@ person_module/test_vifib_user_admin ...@@ -68,6 +68,8 @@ person_module/test_vifib_user_admin
person_module/test_vifib_user_admin/** person_module/test_vifib_user_admin/**
person_module/test_vifib_user_developer person_module/test_vifib_user_developer
person_module/test_vifib_user_developer/** person_module/test_vifib_user_developer/**
portal_caches/slap_cache_factory
portal_caches/slap_cache_factory/persistent_cache_plugin
service_module/computer_registration service_module/computer_registration
service_module/computer_registration/** service_module/computer_registration/**
service_module/vifib_discount service_module/vifib_discount
......
...@@ -38,6 +38,7 @@ from Products.ERP5Type.Globals import InitializeClass ...@@ -38,6 +38,7 @@ from Products.ERP5Type.Globals import InitializeClass
from Products.ERP5Type.Tool.BaseTool import BaseTool from Products.ERP5Type.Tool.BaseTool import BaseTool
from Products.ZSQLCatalog.SQLCatalog import Query, ComplexQuery from Products.ZSQLCatalog.SQLCatalog import Query, ComplexQuery
from Products.ERP5Type import Permissions from Products.ERP5Type import Permissions
from Products.ERP5Type.Cache import CachingMethod
from lxml import etree from lxml import etree
try: try:
from slapos.slap.slap import Computer from slapos.slap.slap import Computer
...@@ -140,19 +141,26 @@ class SlapTool(BaseTool): ...@@ -140,19 +141,26 @@ class SlapTool(BaseTool):
Reuses slap library for easy marshalling. Reuses slap library for easy marshalling.
""" """
self.REQUEST.response.setHeader('Content-Type', 'text/xml')
slap_computer = Computer(computer_id)
parent_uid = self._getComputerUidByReference(computer_id)
slap_computer._computer_partition_list = [] def _getComputerInformation(computer_id, user):
slap_computer._software_release_list = \ self.REQUEST.response.setHeader('Content-Type', 'text/xml')
self._getSoftwareReleaseValueListForComputer(computer_id) slap_computer = Computer(computer_id)
for computer_partition in self.getPortalObject().portal_catalog( parent_uid = self._getComputerUidByReference(computer_id)
parent_uid=parent_uid,
portal_type="Computer Partition"): slap_computer._computer_partition_list = []
slap_computer._computer_partition_list.append( slap_computer._software_release_list = \
self._getSlapPartitionByPackingList(computer_partition.getObject())) self._getSoftwareReleaseValueListForComputer(computer_id)
return xml_marshaller.xml_marshaller.dumps(slap_computer) for computer_partition in self.getPortalObject().portal_catalog(
parent_uid=parent_uid,
portal_type="Computer Partition"):
slap_computer._computer_partition_list.append(
self._getSlapPartitionByPackingList(computer_partition.getObject()))
return xml_marshaller.xml_marshaller.dumps(slap_computer)
user = self.getPortalObject().portal_membership.getAuthenticatedMember().getUserName()
return CachingMethod(_getComputerInformation,
id='_getComputerInformation',
cache_factory='slap_cache_factory')(computer_id, user)
security.declareProtected(Permissions.AccessContentsInformation, security.declareProtected(Permissions.AccessContentsInformation,
'getFullComputerInformation') 'getFullComputerInformation')
......
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