[Erp5-report] r26986 - in /erp5/trunk/products/ERP5Type: Core/ Tool/ tests/
nobody at svn.erp5.org
nobody at svn.erp5.org
Thu May 14 16:32:32 CEST 2009
Author: nicolas
Date: Thu May 14 16:32:29 2009
New Revision: 26986
URL: http://svn.erp5.org?rev=26986&view=rev
Log:
Implement new ZODB Cache
Modified:
erp5/trunk/products/ERP5Type/Core/CacheFactory.py
erp5/trunk/products/ERP5Type/Tool/CacheTool.py
erp5/trunk/products/ERP5Type/tests/testCacheTool.py
Modified: erp5/trunk/products/ERP5Type/Core/CacheFactory.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/Core/CacheFactory.py?rev=26986&r1=26985&r2=26986&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/Core/CacheFactory.py [utf8] (original)
+++ erp5/trunk/products/ERP5Type/Core/CacheFactory.py [utf8] Thu May 14 16:32:29 2009
@@ -1,3 +1,4 @@
+# -*- coding: utf-8 -*-
##############################################################################
#
# Copyright (c) 2005 Nexedi SARL and Contributors. All Rights Reserved.
@@ -47,6 +48,7 @@
allowed_types = ('ERP5 Ram Cache',
'ERP5 Distributed Ram Cache',
'ERP5 SQL Cache',
+ 'ERP5 Zodb Cache',
)
security = ClassSecurityInfo()
Modified: erp5/trunk/products/ERP5Type/Tool/CacheTool.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/Tool/CacheTool.py?rev=26986&r1=26985&r2=26986&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/Tool/CacheTool.py [utf8] (original)
+++ erp5/trunk/products/ERP5Type/Tool/CacheTool.py [utf8] Thu May 14 16:32:29 2009
@@ -1,3 +1,4 @@
+# -*- coding: utf-8 -*-
##############################################################################
#
# Copyright (c) 2005 Nexedi SARL and Contributors. All Rights Reserved.
@@ -39,6 +40,7 @@
from Products.ERP5Type.CachePlugins.RamCache import RamCache
from Products.ERP5Type.CachePlugins.DistributedRamCache import DistributedRamCache
from Products.ERP5Type.CachePlugins.SQLCache import SQLCache
+from Products.ERP5Type.CachePlugins.ZODBCache import ZODBCache
## try to import needed modules for cache plugins
try:
@@ -100,7 +102,9 @@
kw = self.parseDBConnectionString(connection_string)
kw['cache_table_name'] = cp.getCacheTableName()
cache_obj = SQLCache(kw)
- if cache_obj:
+ elif cp_meta_type == 'ERP5 Zodb Cache':
+ cache_obj = ZODBCache(dict(cache_tool=self))
+ if cache_obj is not None:
## set cache expire check interval
cache_obj.cache_expire_check_interval = cp.getCacheExpireCheckInterval()
rd[cache_scope]['cache_plugins'].append(cache_obj)
Modified: erp5/trunk/products/ERP5Type/tests/testCacheTool.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/tests/testCacheTool.py?rev=26986&r1=26985&r2=26986&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/tests/testCacheTool.py [utf8] (original)
+++ erp5/trunk/products/ERP5Type/tests/testCacheTool.py [utf8] Thu May 14 16:32:29 2009
@@ -75,6 +75,7 @@
"Ram Cache",
"Distributed Ram Cache",
"SQL Cache",
+ "Zodb Cache",
)
for typeinfo_name in typeinfo_names:
portal_type = getattr(portal_types, typeinfo_name, None)
@@ -110,6 +111,14 @@
sql_cache_plugin = sql_cache_factory.newContent(
portal_type="SQL Cache", container=sql_cache_factory)
sql_cache_plugin.setIntIndex(0)
+
+ ## zodb_cache_factory (to test ZODB Cache Plugin)
+ zodb_cache_factory = portal_caches.newContent(portal_type="Cache Factory",
+ id='zodb_cache_factory',
+ container=portal_caches)
+ zodb_cache_plugin = zodb_cache_factory.newContent(
+ portal_type="Zodb Cache", container=zodb_cache_factory)
+ zodb_cache_plugin.setIntIndex(0)
## erp5_user_factory (to test a combination of all cache plugins)
erp5_user_factory = portal_caches.newContent(portal_type="Cache Factory",
@@ -125,18 +134,24 @@
sql_cache_plugin = erp5_user_factory.newContent(
portal_type="SQL Cache", container=erp5_user_factory)
sql_cache_plugin.setIntIndex(2)
+ zodb_cache_plugin = erp5_user_factory.newContent(
+ portal_type="Zodb Cache", container=erp5_user_factory)
+ zodb_cache_plugin.setIntIndex(3)
##
transaction.commit()
## update Ram Cache structure
portal_caches.updateCache()
+ ## commit PersistantMapping for zodb_cache
+ transaction.commit()
from Products.ERP5Type.Cache import CachingMethod
## do we have the same structure we created above?
self.assert_('ram_cache_factory' in CachingMethod.factories)
self.assert_('distributed_ram_cache_factory' in CachingMethod.factories)
self.assert_('sql_cache_factory' in CachingMethod.factories)
+ self.assert_('zodb_cache_factory' in CachingMethod.factories)
self.assert_('erp5_user_factory' in CachingMethod.factories)
def test_04_CreateCachedMethod(self):
@@ -172,7 +187,8 @@
py_script_obj = getattr(portal, py_script_id)
for cf_name in ('ram_cache_factory',
'distributed_ram_cache_factory',
- 'sql_cache_factory'):
+ 'sql_cache_factory',
+ 'zodb_cache_factory',):
my_cache = CachingMethod(py_script_obj,
'py_script_obj',
cache_factory=cf_name)
More information about the Erp5-report
mailing list