Commit 330f26f7 authored by Arnaud Fontaine's avatar Arnaud Fontaine

WIP: ZODB Components: Migrate MemcachedTool (portal_memcached) from filesystem.

All {Unit,CodingStyle} Tests pass but SelectionTool may used portal_memcached
so this commit depends on migrating SelectionTool too.
parent 75309541
......@@ -2094,7 +2094,6 @@ class ERP5Generator(PortalGenerator):
# Add ERP5Type Tool
addERP5Tool(p, 'portal_caches', 'Cache Tool')
addERP5Tool(p, 'portal_memcached', 'Memcached Tool')
# Add erp5 catalog tool
addERP5Tool(p, 'portal_catalog', 'Catalog Tool')
......
......@@ -31,7 +31,7 @@ from AccessControl import ClassSecurityInfo
from Products.ERP5Type.XMLObject import XMLObject
from Products.ERP5Type import PropertySheet
from Products.ERP5Type import Permissions
from Products.ERP5Type.Tool.MemcachedTool import MemcachedDict
from erp5.component.tool.MemcachedTool import MemcachedDict
from Products.ERP5Type.Globals import InitializeClass
class MemcachedPlugin(XMLObject):
......@@ -61,7 +61,7 @@ class MemcachedPlugin(XMLObject):
security.declarePublic('getConnection')
def getConnection(self):
try:
key, connection = self._v_connection
key, connection = self._v_connection # pylint: disable=access-member-before-definition
except AttributeError:
key = None
url = self.getUrlString()
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Document Component" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>default_reference</string> </key>
<value> <string>MemcachedPlugin</string> </value>
</item>
<item>
<key> <string>default_source_reference</string> </key>
<value> <string>Products.ERP5Type.Core.MemcachedPlugin</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>document.erp5.MemcachedPlugin</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Document 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="Tool Component" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>default_reference</string> </key>
<value> <string>MemcachedTool</string> </value>
</item>
<item>
<key> <string>default_source_reference</string> </key>
<value> <string>Products.ERP5Type.Tool.MemcachedTool</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>tool.erp5.MemcachedTool</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="Memcached 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_memcached</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>
......@@ -24,6 +24,7 @@ document.erp5.InvoiceLine
document.erp5.Item
document.erp5.MailMessage
document.erp5.MappedValue
document.erp5.MemcachedPlugin
document.erp5.Movement
document.erp5.Order
document.erp5.PackingList
......
......@@ -7,6 +7,7 @@ tool.erp5.DeliveryTool
tool.erp5.DiffTool
tool.erp5.DomainTool
tool.erp5.IntrospectionTool
tool.erp5.MemcachedTool
tool.erp5.NotificationTool
tool.erp5.OrderTool
tool.erp5.PasswordTool
......
......@@ -7,6 +7,7 @@ portal_diff
portal_domains
portal_ids
portal_introspections
portal_memcached
portal_notifications
portal_orders
portal_password
......
......@@ -38,11 +38,6 @@ from Products.ERP5Type import interfaces
import zope.interface
from base64 import encodestring
try:
from Products.ERP5Type.Tool.MemcachedTool import MemcachedDict, SharedDict
except ImportError:
LOG('DistributedRamCache', 0, 'unable to import memcache')
## global dictionary containing connection objects
connection_pool = local()
......@@ -83,6 +78,7 @@ class DistributedRamCache(BaseCache):
try:
dictionary = local_dict[configuration_key]
except KeyError:
from erp5.component.tool.MemcachedTool import MemcachedDict
dictionary = MemcachedDict(self._servers.split('\n'),
expiration_time=self._expiration_time,
server_max_key_length=self._server_max_key_length,
......@@ -93,6 +89,7 @@ class DistributedRamCache(BaseCache):
def getCacheStorage(self, **kw):
"""Follow MemcachedTool.getMemcachedDict implementation
"""
from erp5.component.tool.MemcachedTool import SharedDict
return SharedDict(self._getMemcachedDict(), prefix=self._key_prefix)
def _getCacheId(self, cache_id, scope):
......
This diff is collapsed.
......@@ -88,7 +88,7 @@ import Products.ERP5Type.Workflow
def initialize( context ):
# Import Product Components
from Tool import (CacheTool, MemcachedTool,
from Tool import (CacheTool,
TypesTool, PropertySheetTool,
ComponentTool)
import Document
......@@ -103,7 +103,6 @@ def initialize( context ):
XMLObject.XMLObject,
ERP5TypeInformation, )
portal_tools = ( CacheTool.CacheTool,
MemcachedTool.MemcachedTool,
TypesTool.TypesTool,
PropertySheetTool.PropertySheetTool,
ComponentTool.ComponentTool
......
......@@ -1000,11 +1000,17 @@ class ERP5TypeCommandLineTestCase(ERP5TypeTestCaseMixin):
def _updateMemcachedConfiguration(self):
"""Update default memcached plugin configuration
"""
portal_memcached = self.portal.portal_memcached
try:
default_memcached_plugin = self.portal.portal_memcached.default_memcached_plugin
# May not be present after upgrading from filesystem to ZODB Components
# (testUpgradeInstanceWithOldDataFs)
except AttributeError:
pass
else:
connection_dict = _getVolatileMemcachedServerDict()
url_string = '%(hostname)s:%(port)s' % connection_dict
if portal_memcached.default_memcached_plugin.getUrlString() != url_string:
portal_memcached.default_memcached_plugin.setUrlString(url_string)
if default_memcached_plugin.getUrlString() != url_string:
default_memcached_plugin.setUrlString(url_string)
def _clearActivity(self, quiet=0):
"""Clear activities if `erp5_tests_recreate_catalog` environment variable is
......
......@@ -257,8 +257,7 @@ def installRealMemcachedTool(portal):
def _recreateMemcachedTool(portal):
"""Recreate the memcached tool for this portal.
"""
from Products.ERP5Type.Tool import MemcachedTool
reload(MemcachedTool)
portal.portal_components.reset(force=True)
portal.manage_delObjects(['portal_memcached'])
portal.newContent(id='portal_memcached', portal_type="Memcached Tool")
......
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