From 99f21941d488b8bfee12711d1d9e3ebeae491bd8 Mon Sep 17 00:00:00 2001
From: Nicolas Delaby <nicolas@nexedi.com>
Date: Wed, 3 Jun 2009 09:20:39 +0000
Subject: [PATCH] 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
---
 product/ERP5Type/Core/CacheFactory.py   |  6 +--
 product/ERP5Type/Tool/CacheTool.py      | 65 -------------------------
 product/ERP5Type/tests/testCacheTool.py | 37 +-------------
 3 files changed, 3 insertions(+), 105 deletions(-)

diff --git a/product/ERP5Type/Core/CacheFactory.py b/product/ERP5Type/Core/CacheFactory.py
index c1f612de1a..747401918f 100644
--- a/product/ERP5Type/Core/CacheFactory.py
+++ b/product/ERP5Type/Core/CacheFactory.py
@@ -46,9 +46,7 @@ class CacheFactory(XMLObject):
   isRADContent = 1
 
   allowed_types = ('ERP5 Ram Cache', 
-                   'ERP5 Distributed Ram Cache', 
-                   'ERP5 SQL Cache',
-                   'ERP5 ZODB Cache',
+                   'ERP5 Distributed Ram Cache',
                   )
 
   security = ClassSecurityInfo()
@@ -61,7 +59,7 @@ class CacheFactory(XMLObject):
   property_sheets = ( PropertySheet.Base
                     , PropertySheet.SimpleItem
                     , PropertySheet.Folder
-                    , CacheFactory  
+                    , CacheFactory
                     )
 
 
diff --git a/product/ERP5Type/Tool/CacheTool.py b/product/ERP5Type/Tool/CacheTool.py
index 14c651113d..5620be0cf8 100644
--- a/product/ERP5Type/Tool/CacheTool.py
+++ b/product/ERP5Type/Tool/CacheTool.py
@@ -39,8 +39,6 @@ from Products.ERP5Type.Cache import CachingMethod
 from Products.ERP5Type.Cache import DEFAULT_CACHE_FACTORY
 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:
@@ -96,14 +94,6 @@ class CacheTool(BaseTool):
             ## 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':
-          ## 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:
           ## set cache expire check interval
           cache_obj.cache_expire_check_interval = cp.getCacheExpireCheckInterval()
@@ -111,61 +101,6 @@ class CacheTool(BaseTool):
           rd[cache_scope]['cache_params']['cache_duration'] = cf.getCacheDuration()
     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
   ##
diff --git a/product/ERP5Type/tests/testCacheTool.py b/product/ERP5Type/tests/testCacheTool.py
index 91c7b2ba58..5b495900eb 100644
--- a/product/ERP5Type/tests/testCacheTool.py
+++ b/product/ERP5Type/tests/testCacheTool.py
@@ -78,8 +78,6 @@ class TestCacheTool(ERP5TypeTestCase):
     typeinfo_names = ("Cache Factory",
                       "Ram Cache",
                       "Distributed Ram Cache",
-                      "SQL Cache",
-                      "Zodb Cache",
                       )
     for typeinfo_name in typeinfo_names:
       portal_type = getattr(portal_types, typeinfo_name, None)
@@ -108,24 +106,6 @@ class TestCacheTool(ERP5TypeTestCase):
               portal_type="Distributed Ram Cache", container=dram_cache_factory)
       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:
 
       ## erp5_user_factory (to test a combination of all cache plugins)
@@ -139,13 +119,6 @@ class TestCacheTool(ERP5TypeTestCase):
       dram_cache_plugin = erp5_user_factory.newContent(
               portal_type="Distributed Ram Cache", container=erp5_user_factory)
       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
     portal_caches.updateCache()
 
@@ -154,8 +127,6 @@ class TestCacheTool(ERP5TypeTestCase):
     ## 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 createCachedMethod(self):
@@ -191,8 +162,7 @@ return result
     py_script_obj = getattr(portal, py_script_id)
     for cf_name in ('ram_cache_factory',
                     'distributed_ram_cache_factory',
-                    'sql_cache_factory',
-                    'zodb_cache_factory',):
+                   ):
       my_cache = CachingMethod(py_script_obj,
                                'py_script_obj',
                                cache_factory=cf_name)
@@ -277,15 +247,10 @@ return result
     """
     from Products.ERP5Type.CachePlugins.DistributedRamCache import DistributedRamCache
     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 Interface.Verify import verifyClass
-    verifyClass(ICachePlugin, ZODBCache)
     verifyClass(ICachePlugin, DistributedRamCache)
     verifyClass(ICachePlugin, RamCache)
-    verifyClass(ICachePlugin, SQLCache)
-
 
 def test_suite():
   suite = unittest.TestSuite()
-- 
2.30.9