Commit 99f21941 authored by Nicolas Delaby's avatar Nicolas Delaby

remove all reference to SQLCache and ZODB Cache

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@27346 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 16364002
...@@ -46,9 +46,7 @@ class CacheFactory(XMLObject): ...@@ -46,9 +46,7 @@ class CacheFactory(XMLObject):
isRADContent = 1 isRADContent = 1
allowed_types = ('ERP5 Ram Cache', allowed_types = ('ERP5 Ram Cache',
'ERP5 Distributed Ram Cache', 'ERP5 Distributed Ram Cache',
'ERP5 SQL Cache',
'ERP5 ZODB Cache',
) )
security = ClassSecurityInfo() security = ClassSecurityInfo()
...@@ -61,7 +59,7 @@ class CacheFactory(XMLObject): ...@@ -61,7 +59,7 @@ class CacheFactory(XMLObject):
property_sheets = ( PropertySheet.Base property_sheets = ( PropertySheet.Base
, PropertySheet.SimpleItem , PropertySheet.SimpleItem
, PropertySheet.Folder , PropertySheet.Folder
, CacheFactory , CacheFactory
) )
......
...@@ -39,8 +39,6 @@ from Products.ERP5Type.Cache import CachingMethod ...@@ -39,8 +39,6 @@ from Products.ERP5Type.Cache import CachingMethod
from Products.ERP5Type.Cache import DEFAULT_CACHE_FACTORY from Products.ERP5Type.Cache import DEFAULT_CACHE_FACTORY
from Products.ERP5Type.CachePlugins.RamCache import RamCache from Products.ERP5Type.CachePlugins.RamCache import RamCache
from Products.ERP5Type.CachePlugins.DistributedRamCache import DistributedRamCache 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 to import needed modules for cache plugins
try: try:
...@@ -96,14 +94,6 @@ class CacheTool(BaseTool): ...@@ -96,14 +94,6 @@ class CacheTool(BaseTool):
## we don't have memcache python module installed ## we don't have memcache python module installed
## thus we can't use DistributedRamCache plugin ## thus we can't use DistributedRamCache plugin
cache_obj = None cache_obj = None
elif cp_meta_type == 'ERP5 SQL Cache':
## 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)
elif cp_meta_type == 'ERP5 ZODB Cache':
cache_obj = ZODBCache(dict(cache_tool=self))
if cache_obj is not None: if cache_obj is not None:
## set cache expire check interval ## set cache expire check interval
cache_obj.cache_expire_check_interval = cp.getCacheExpireCheckInterval() cache_obj.cache_expire_check_interval = cp.getCacheExpireCheckInterval()
...@@ -111,61 +101,6 @@ class CacheTool(BaseTool): ...@@ -111,61 +101,6 @@ class CacheTool(BaseTool):
rd[cache_scope]['cache_params']['cache_duration'] = cf.getCacheDuration() rd[cache_scope]['cache_params']['cache_duration'] = cf.getCacheDuration()
return rd return rd
##
## DB structure
##
security.declareProtected(Permissions.ModifyPortalContent, 'createDBCacheTable')
def createDBCacheTable(self, cache_table_name="cache", REQUEST=None):
""" create in MySQL DB cache table """
my_query = SQLCache.create_table_sql %cache_table_name
try:
self.erp5_sql_transactionless_connection.manage_test("DROP TABLE %s" %cache_table_name)
except:
pass
self.erp5_sql_transactionless_connection.manage_test(my_query)
if REQUEST is not None:
self.REQUEST.RESPONSE.redirect('cache_tool_configure?manage_tabs_message=Cache table successfully created.')
security.declareProtected(Permissions.AccessContentsInformation, 'parseDBConnectionString')
def parseDBConnectionString(self, connection_string):
""" Parse given connection string. Code "borrowed" from ZMySLQDA.db """
kwargs = {}
items = connection_string.split()
if not items:
return kwargs
compress = items[0]
if compress == "~":
kwargs['compress'] = True
items = items[1:]
lockreq, items = items[0], items[1:]
if lockreq[0] == "*":
db_host, items = items[0], items[1:]
else:
db_host = lockreq
if '@' in db_host:
db, host = db_host.split('@',1)
kwargs['db'] = db
if ':' in host:
host, port = host.split(':',1)
kwargs['port'] = int(port)
kwargs['host'] = host
else:
kwargs['db'] = db_host
if kwargs['db'] and kwargs['db'][0] in ('+', '-'):
kwargs['db'] = kwargs['db'][1:]
if not kwargs['db']:
del kwargs['db']
if not items:
return kwargs
kwargs['user'], items = items[0], items[1:]
if not items:
return kwargs
kwargs['passwd'], items = items[0], items[1:]
if not items:
return kwargs
kwargs['unix_socket'], items = items[0], items[1:]
return kwargs
## ##
## RAM cache structure ## RAM cache structure
## ##
......
...@@ -78,8 +78,6 @@ class TestCacheTool(ERP5TypeTestCase): ...@@ -78,8 +78,6 @@ class TestCacheTool(ERP5TypeTestCase):
typeinfo_names = ("Cache Factory", typeinfo_names = ("Cache Factory",
"Ram Cache", "Ram Cache",
"Distributed Ram Cache", "Distributed Ram Cache",
"SQL Cache",
"Zodb Cache",
) )
for typeinfo_name in typeinfo_names: for typeinfo_name in typeinfo_names:
portal_type = getattr(portal_types, typeinfo_name, None) portal_type = getattr(portal_types, typeinfo_name, None)
...@@ -108,24 +106,6 @@ class TestCacheTool(ERP5TypeTestCase): ...@@ -108,24 +106,6 @@ class TestCacheTool(ERP5TypeTestCase):
portal_type="Distributed Ram Cache", container=dram_cache_factory) portal_type="Distributed Ram Cache", container=dram_cache_factory)
dram_cache_plugin.setIntIndex(0) dram_cache_plugin.setIntIndex(0)
if getattr(portal_caches, 'sql_cache_factory', None) is None:
## sql_cache_factory (to test SQL Cache Plugin)
sql_cache_factory = portal_caches.newContent(portal_type="Cache Factory",
id='sql_cache_factory',
container=portal_caches)
sql_cache_plugin = sql_cache_factory.newContent(
portal_type="SQL Cache", container=sql_cache_factory)
sql_cache_plugin.setIntIndex(0)
if getattr(portal_caches, 'zodb_cache_factory', None) is None:
## 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)
if getattr(portal_caches, 'erp5_user_factory', None) is None: if getattr(portal_caches, 'erp5_user_factory', None) is None:
## erp5_user_factory (to test a combination of all cache plugins) ## erp5_user_factory (to test a combination of all cache plugins)
...@@ -139,13 +119,6 @@ class TestCacheTool(ERP5TypeTestCase): ...@@ -139,13 +119,6 @@ class TestCacheTool(ERP5TypeTestCase):
dram_cache_plugin = erp5_user_factory.newContent( dram_cache_plugin = erp5_user_factory.newContent(
portal_type="Distributed Ram Cache", container=erp5_user_factory) portal_type="Distributed Ram Cache", container=erp5_user_factory)
dram_cache_plugin.setIntIndex(1) dram_cache_plugin.setIntIndex(1)
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)
## update Ram Cache structure ## update Ram Cache structure
portal_caches.updateCache() portal_caches.updateCache()
...@@ -154,8 +127,6 @@ class TestCacheTool(ERP5TypeTestCase): ...@@ -154,8 +127,6 @@ class TestCacheTool(ERP5TypeTestCase):
## do we have the same structure we created above? ## do we have the same structure we created above?
self.assert_('ram_cache_factory' in CachingMethod.factories) self.assert_('ram_cache_factory' in CachingMethod.factories)
self.assert_('distributed_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) self.assert_('erp5_user_factory' in CachingMethod.factories)
def createCachedMethod(self): def createCachedMethod(self):
...@@ -191,8 +162,7 @@ return result ...@@ -191,8 +162,7 @@ return result
py_script_obj = getattr(portal, py_script_id) py_script_obj = getattr(portal, py_script_id)
for cf_name in ('ram_cache_factory', for cf_name in ('ram_cache_factory',
'distributed_ram_cache_factory', 'distributed_ram_cache_factory',
'sql_cache_factory', ):
'zodb_cache_factory',):
my_cache = CachingMethod(py_script_obj, my_cache = CachingMethod(py_script_obj,
'py_script_obj', 'py_script_obj',
cache_factory=cf_name) cache_factory=cf_name)
...@@ -277,15 +247,10 @@ return result ...@@ -277,15 +247,10 @@ return result
""" """
from Products.ERP5Type.CachePlugins.DistributedRamCache import DistributedRamCache from Products.ERP5Type.CachePlugins.DistributedRamCache import DistributedRamCache
from Products.ERP5Type.CachePlugins.RamCache import RamCache from Products.ERP5Type.CachePlugins.RamCache import RamCache
from Products.ERP5Type.CachePlugins.SQLCache import SQLCache
from Products.ERP5Type.CachePlugins.ZODBCache import ZODBCache
from Products.ERP5Type.interfaces.cache_plugin import ICachePlugin from Products.ERP5Type.interfaces.cache_plugin import ICachePlugin
from Interface.Verify import verifyClass from Interface.Verify import verifyClass
verifyClass(ICachePlugin, ZODBCache)
verifyClass(ICachePlugin, DistributedRamCache) verifyClass(ICachePlugin, DistributedRamCache)
verifyClass(ICachePlugin, RamCache) verifyClass(ICachePlugin, RamCache)
verifyClass(ICachePlugin, SQLCache)
def test_suite(): def test_suite():
suite = unittest.TestSuite() suite = unittest.TestSuite()
......
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