[Erp5-report] r11046 - /erp5/trunk/products/ERP5/Tool/CacheTool.py
nobody at svn.erp5.org
nobody at svn.erp5.org
Thu Nov 2 10:03:27 CET 2006
Author: ivan
Date: Thu Nov 2 10:03:21 2006
New Revision: 11046
URL: http://svn.erp5.org?rev=11046&view=rev
Log:
Removed dependency of memcache module for DistributedRamCache plugin
Modified:
erp5/trunk/products/ERP5/Tool/CacheTool.py
Modified: erp5/trunk/products/ERP5/Tool/CacheTool.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/Tool/CacheTool.py?rev=11046&r1=11045&r2=11046&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/Tool/CacheTool.py (original)
+++ erp5/trunk/products/ERP5/Tool/CacheTool.py Thu Nov 2 10:03:21 2006
@@ -38,6 +38,11 @@
from Products.ERP5Type.CachePlugins.DistributedRamCache import DistributedRamCache
from Products.ERP5Type.CachePlugins.SQLCache import SQLCache
+## try to import needed modules for cache plugins
+try:
+ import memcache
+except ImportError:
+ pass
class CacheTool(BaseTool):
""" Caches tool wrapper for ERP5 """
@@ -67,21 +72,30 @@
rd[cache_scope]['cache_plugins'] = []
rd[cache_scope]['cache_params'] = {}
for cp in cf.getCachePluginList():
+ cache_obj = None
cp_meta_type = cp.meta_type
if cp_meta_type == 'ERP5 Ram Cache Plugin':
cache_obj = RamCache()
elif cp_meta_type == 'ERP5 Distributed Ram Cache Plugin':
- cache_obj = DistributedRamCache({'server':cp.getServer()})
+ ## even thougn we have such plugin in ZODB that doens't mean
+ ## we have corresponding memcache module installed
+ if 'memcache' in globals().keys():
+ cache_obj = DistributedRamCache({'server':cp.getServer()})
+ else:
+ ## we don't have memcache python module installed
+ ## thus we can't use DistributedRamCache plugin
+ cache_obj = None
elif cp_meta_type == 'ERP5 SQL Cache Plugin':
## use connection details from 'erp5_sql_transactionless_connection' ZMySLQDA object
connection_string = self.erp5_sql_transactionless_connection.connection_string
kw = self.parseDBConnectionString(connection_string)
kw['cache_table_name'] = cp.getCacheTableName()
cache_obj = SQLCache(kw)
- ## set cache expire check interval
- cache_obj.cache_expire_check_interval = cp.getCacheExpireCheckInterval()
- rd[cache_scope]['cache_plugins'].append(cache_obj)
- rd[cache_scope]['cache_params']['cache_duration'] = cf.getCacheDuration()
+ if cache_obj:
+ ## set cache expire check interval
+ cache_obj.cache_expire_check_interval = cp.getCacheExpireCheckInterval()
+ rd[cache_scope]['cache_plugins'].append(cache_obj)
+ rd[cache_scope]['cache_params']['cache_duration'] = cf.getCacheDuration()
return rd
##
More information about the Erp5-report
mailing list