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 @@
#
##############################################################################
from Products.ERP5Type import allowMemcachedTool
from Products.ERP5Type.Tool.BaseTool import BaseTool
from Products.ERP5Type import Permissions, _dtmldir
from AccessControl import ClassSecurityInfo
......@@ -34,7 +33,13 @@ from Globals import DTMLFile
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 traceback
from Shared.DC.ZRDB.TM import TM
......@@ -306,7 +311,7 @@ if allowMemcachedTool():
self._v_memcached_dict = None
else:
# Placeholder memcache tool
class MemcachedTool(BaseTool):
"""
Dummy MemcachedTool placeholder.
......@@ -326,10 +331,8 @@ else:
if this function is called and memcachedtool is disabled, fail loudly
with a meaningfull message.
"""
from Products.ERP5Type import memcached_tool_enable_path
raise RuntimeError, 'MemcachedTool is disabled. You should ask'\
' the server administrator to enable it by creating the file %s' % \
(memcached_tool_enable_path, )
raise RuntimeError, 'MemcachedTool is disabled. You should ask the'\
' server administrator to enable it by installing python-memcached.'
setServerAddress = failingMethod
getServerAddress = failingMethod
......@@ -337,4 +340,3 @@ else:
setServerAddressList = failingMethod
memcached_tool_configure = failingMethod
getMemcachedDict = failingMethod
......@@ -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
# production environment
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():
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 ):
# Import Product Components
from Tool import ClassTool, CacheTool, MemcachedTool, SessionTool
......
......@@ -99,7 +99,6 @@ def _recreateClassTool(portal):
def installRealMemcachedTool(portal):
"""Replaces portal_memcached by a real memcached tool object.
"""
Products.ERP5Type.allowMemcachedTool = lambda: 1
_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