Commit 7d27abd0 authored by Kazuhiko Shiozaki's avatar Kazuhiko Shiozaki

enable memcached tool by the existence of python-memcached (Bug #632).


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@13940 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 15925f94
...@@ -26,7 +26,6 @@ ...@@ -26,7 +26,6 @@
# #
############################################################################## ##############################################################################
from Products.ERP5Type import allowMemcachedTool
from Products.ERP5Type.Tool.BaseTool import BaseTool from Products.ERP5Type.Tool.BaseTool import BaseTool
from Products.ERP5Type import Permissions, _dtmldir from Products.ERP5Type import Permissions, _dtmldir
from AccessControl import ClassSecurityInfo from AccessControl import ClassSecurityInfo
...@@ -34,7 +33,13 @@ from Globals import DTMLFile ...@@ -34,7 +33,13 @@ from Globals import DTMLFile
MEMCACHED_TOOL_MODIFIED_FLAG_PROPERTY_ID = '_v_memcached_edited' MEMCACHED_TOOL_MODIFIED_FLAG_PROPERTY_ID = '_v_memcached_edited'
if allowMemcachedTool(): try:
import memcache
except ImportError:
memcache = None
if memcache is not None:
# Real memcache tool
import memcache import memcache
import traceback import traceback
from Shared.DC.ZRDB.TM import TM from Shared.DC.ZRDB.TM import TM
...@@ -305,8 +310,8 @@ if allowMemcachedTool(): ...@@ -305,8 +310,8 @@ if allowMemcachedTool():
self.server_address_list = value self.server_address_list = value
self._v_memcached_dict = None self._v_memcached_dict = None
else: else:
# Placeholder memcache tool
class MemcachedTool(BaseTool): class MemcachedTool(BaseTool):
""" """
Dummy MemcachedTool placeholder. Dummy MemcachedTool placeholder.
...@@ -326,10 +331,8 @@ else: ...@@ -326,10 +331,8 @@ else:
if this function is called and memcachedtool is disabled, fail loudly if this function is called and memcachedtool is disabled, fail loudly
with a meaningfull message. with a meaningfull message.
""" """
from Products.ERP5Type import memcached_tool_enable_path raise RuntimeError, 'MemcachedTool is disabled. You should ask the'\
raise RuntimeError, 'MemcachedTool is disabled. You should ask'\ ' server administrator to enable it by installing python-memcached.'
' the server administrator to enable it by creating the file %s' % \
(memcached_tool_enable_path, )
setServerAddress = failingMethod setServerAddress = failingMethod
getServerAddress = failingMethod getServerAddress = failingMethod
...@@ -337,4 +340,3 @@ else: ...@@ -337,4 +340,3 @@ else:
setServerAddressList = failingMethod setServerAddressList = failingMethod
memcached_tool_configure = failingMethod memcached_tool_configure = failingMethod
getMemcachedDict = failingMethod getMemcachedDict = failingMethod
...@@ -50,14 +50,10 @@ import Products.Localizer # So that we make sure Globals.get_request is availabl ...@@ -50,14 +50,10 @@ import Products.Localizer # So that we make sure Globals.get_request is availabl
# read permissions for zope - this prevents security holes in # read permissions for zope - this prevents security holes in
# production environment # production environment
class_tool_security_path = '%s%s%s' % (product_path, os.sep, 'ALLOW_CLASS_TOOL') class_tool_security_path = '%s%s%s' % (product_path, os.sep, 'ALLOW_CLASS_TOOL')
memcached_tool_enable_path = '%s%s%s' % (product_path, os.sep, 'USE_MEMCACHED_TOOL')
def allowClassTool(): def allowClassTool():
return os.access(class_tool_security_path, os.F_OK) return os.access(class_tool_security_path, os.F_OK)
def allowMemcachedTool():
return os.access(memcached_tool_enable_path, os.F_OK)
def initialize( context ): def initialize( context ):
# Import Product Components # Import Product Components
from Tool import ClassTool, CacheTool, MemcachedTool, SessionTool from Tool import ClassTool, CacheTool, MemcachedTool, SessionTool
......
...@@ -99,7 +99,6 @@ def _recreateClassTool(portal): ...@@ -99,7 +99,6 @@ def _recreateClassTool(portal):
def installRealMemcachedTool(portal): def installRealMemcachedTool(portal):
"""Replaces portal_memcached by a real memcached tool object. """Replaces portal_memcached by a real memcached tool object.
""" """
Products.ERP5Type.allowMemcachedTool = lambda: 1
_recreateMemcachedTool(portal) _recreateMemcachedTool(portal)
def _recreateMemcachedTool(portal): def _recreateMemcachedTool(portal):
......
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