Commit e772b4fb authored by Arnaud Fontaine's avatar Arnaud Fontaine

WIP: CacheTool

parent f72afbba
...@@ -5482,7 +5482,13 @@ Business Template is a set of definitions, such as skins, portal types and categ ...@@ -5482,7 +5482,13 @@ Business Template is a set of definitions, such as skins, portal types and categ
site.ERP5Site_updateTranslationTable() site.ERP5Site_updateTranslationTable()
# Clear cache to avoid reusing cached values with replaced objects. # Clear cache to avoid reusing cached values with replaced objects.
site.portal_caches.clearAllCache() try:
cache_tool = site.portal_caches
except AttributeError:
# Only happen when installing erp5_core shipping portal_caches
pass
else:
cache_tool.clearAllCache()
security.declareProtected(Permissions.ManagePortal, 'install') security.declareProtected(Permissions.ManagePortal, 'install')
install = _install install = _install
......
...@@ -2093,7 +2093,6 @@ class ERP5Generator(PortalGenerator): ...@@ -2093,7 +2093,6 @@ class ERP5Generator(PortalGenerator):
addERP5Tool(p, 'portal_alarms', 'Alarm Tool') addERP5Tool(p, 'portal_alarms', 'Alarm Tool')
# Add ERP5Type Tool # Add ERP5Type Tool
addERP5Tool(p, 'portal_caches', 'Cache Tool')
addERP5Tool(p, 'portal_memcached', 'Memcached Tool') addERP5Tool(p, 'portal_memcached', 'Memcached Tool')
# Add erp5 catalog tool # Add erp5 catalog tool
......
...@@ -33,7 +33,7 @@ import transaction ...@@ -33,7 +33,7 @@ import transaction
from AccessControl import ClassSecurityInfo from AccessControl import ClassSecurityInfo
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.Globals import InitializeClass, DTMLFile, PersistentMapping from Products.ERP5Type.Globals import DTMLFile
from Products.ERP5Type import _dtmldir from Products.ERP5Type import _dtmldir
from Products.ERP5Type.Cache import CacheFactory from Products.ERP5Type.Cache import CacheFactory
from Products.ERP5Type.Cache import CachingMethod from Products.ERP5Type.Cache import CachingMethod
...@@ -69,9 +69,9 @@ class CacheTool(BaseTool): ...@@ -69,9 +69,9 @@ class CacheTool(BaseTool):
def getRamCachePlugin(cp): def getRamCachePlugin(cp):
cp_meta_type = cp.meta_type cp_meta_type = cp.meta_type
id = cp.getCacheId() id_ = cp.getCacheId()
if cp_meta_type == 'ERP5 Ram Cache': if cp_meta_type == 'ERP5 Ram Cache':
return RamCache(id) return RamCache(id_)
if cp_meta_type == 'ERP5 Distributed Ram Cache': if cp_meta_type == 'ERP5 Distributed Ram Cache':
## even thougn we have such plugin in ZODB that doens't mean ## even thougn we have such plugin in ZODB that doens't mean
## we have corresponding memcache module installed ## we have corresponding memcache module installed
...@@ -85,7 +85,7 @@ class CacheTool(BaseTool): ...@@ -85,7 +85,7 @@ class CacheTool(BaseTool):
'server_max_key_length': memcached_plugin.getServerMaxKeyLength(), 'server_max_key_length': memcached_plugin.getServerMaxKeyLength(),
'server_max_value_length': memcached_plugin.getServerMaxValueLength(), 'server_max_value_length': memcached_plugin.getServerMaxValueLength(),
'key_prefix': getattr(self, 'erp5_site_global_id', '')} 'key_prefix': getattr(self, 'erp5_site_global_id', '')}
return DistributedRamCache(id, init_dict) return DistributedRamCache(id_, init_dict)
rd = {} rd = {}
for cf in self.objectValues('ERP5 Cache Factory'): for cf in self.objectValues('ERP5 Cache Factory'):
...@@ -184,7 +184,6 @@ class CacheTool(BaseTool): ...@@ -184,7 +184,6 @@ class CacheTool(BaseTool):
assert REQUEST is None assert REQUEST is None
transaction.get().addBeforeCommitHook(self.clearCache, transaction.get().addBeforeCommitHook(self.clearCache,
(cache_factory_list,)) (cache_factory_list,))
ram_cache_root = self.getRamCacheRoot()
for cf_key in cache_factory_list: for cf_key in cache_factory_list:
self.clearCacheFactory(cf_key) self.clearCacheFactory(cf_key)
if REQUEST is not None: if REQUEST is not None:
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Tool Component" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>default_reference</string> </key>
<value> <string>CacheTool</string> </value>
</item>
<item>
<key> <string>default_source_reference</string> </key>
<value> <string>Products.ERP5Type.Tool.CacheTool</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>tool.erp5.CacheTool</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Tool Component</string> </value>
</item>
<item>
<key> <string>sid</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>text_content_error_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>text_content_warning_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>version</string> </key>
<value> <string>erp5</string> </value>
</item>
<item>
<key> <string>workflow_history</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary>
<item>
<key> <string>component_validation_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>validate</string> </value>
</item>
<item>
<key> <string>validation_state</string> </key>
<value> <string>validated</string> </value>
</item>
</dictionary>
</list>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Cache Tool" 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>id</string> </key>
<value> <string>portal_caches</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>
tool.erp5.AcknowledgementTool tool.erp5.AcknowledgementTool
tool.erp5.BuilderTool tool.erp5.BuilderTool
tool.erp5.CacheTool
tool.erp5.CallableTool tool.erp5.CallableTool
tool.erp5.ContributionRegistryTool tool.erp5.ContributionRegistryTool
tool.erp5.DeliveryTool tool.erp5.DeliveryTool
......
mimetypes_registry mimetypes_registry
portal_acknowledgements portal_acknowledgements
portal_caches
portal_callables portal_callables
portal_contribution_registry portal_contribution_registry
portal_deliveries portal_deliveries
......
...@@ -88,7 +88,7 @@ import Products.ERP5Type.Workflow ...@@ -88,7 +88,7 @@ import Products.ERP5Type.Workflow
def initialize( context ): def initialize( context ):
# Import Product Components # Import Product Components
from Tool import (CacheTool, MemcachedTool, SessionTool, from Tool import (MemcachedTool, SessionTool,
TypesTool, WebServiceTool, PropertySheetTool, TypesTool, WebServiceTool, PropertySheetTool,
ComponentTool) ComponentTool)
import Document import Document
...@@ -102,8 +102,7 @@ def initialize( context ): ...@@ -102,8 +102,7 @@ def initialize( context ):
content_classes = ( Base, content_classes = ( Base,
XMLObject.XMLObject, XMLObject.XMLObject,
ERP5TypeInformation, ) ERP5TypeInformation, )
portal_tools = ( CacheTool.CacheTool, portal_tools = ( MemcachedTool.MemcachedTool,
MemcachedTool.MemcachedTool,
SessionTool.SessionTool, SessionTool.SessionTool,
TypesTool.TypesTool, TypesTool.TypesTool,
WebServiceTool.WebServiceTool, WebServiceTool.WebServiceTool,
......
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