Commit 3e5c5c52 authored by Aurel's avatar Aurel

use queryUtility to look after the portal_membership

parent 2bead3b5
...@@ -38,6 +38,7 @@ import sys ...@@ -38,6 +38,7 @@ import sys
import inspect import inspect
import persistent import persistent
from hashlib import md5 as md5_new, sha1 as sha_new from hashlib import md5 as md5_new, sha1 as sha_new
from zope.component import queryUtility
from Products.ERP5Type.Globals import package_home from Products.ERP5Type.Globals import package_home
from Products.ERP5Type.Globals import DevelopmentMode from Products.ERP5Type.Globals import DevelopmentMode
from Acquisition import aq_base from Acquisition import aq_base
...@@ -57,6 +58,7 @@ from Products.CMFCore.utils import getToolByName ...@@ -57,6 +58,7 @@ from Products.CMFCore.utils import getToolByName
from Products.PageTemplates.Expressions import getEngine from Products.PageTemplates.Expressions import getEngine
from Products.PageTemplates.Expressions import SecureModuleImporter from Products.PageTemplates.Expressions import SecureModuleImporter
from Products.ZCatalog.Lazy import LazyMap from Products.ZCatalog.Lazy import LazyMap
from Products.CMFCore.interfaces import IMembershipTool
try: try:
import chardet import chardet
...@@ -1244,6 +1246,18 @@ def initializeProduct( context, ...@@ -1244,6 +1246,18 @@ def initializeProduct( context,
ExpressionEngine = getEngine() ExpressionEngine = getEngine()
CompilerError = ExpressionEngine.getCompilerError() CompilerError = ExpressionEngine.getCompilerError()
def migratePM():
from Products.CMFCore.MembershipTool import MembershipTool
tool = getattr(portal, "portal_membership", None)
if tool and tool.__class__ is not MembershipTool:
assert not tool._p_changed
tool.__class__ = MembershipTool
assert tool._p_changed
migrate = True
def createExpressionContext(object, portal=None): def createExpressionContext(object, portal=None):
""" """
Return a context used for evaluating a TALES expression. Return a context used for evaluating a TALES expression.
...@@ -1271,7 +1285,7 @@ def createExpressionContext(object, portal=None): ...@@ -1271,7 +1285,7 @@ def createExpressionContext(object, portal=None):
folder = aq_parent(aq_inner(folder)) folder = aq_parent(aq_inner(folder))
if portal is not None: if portal is not None:
pm = getattr(portal, 'portal_membership', None) pm = queryUtility(IMembershipTool)
if pm is None or pm.isAnonymousUser(): if pm is None or pm.isAnonymousUser():
member = None member = None
else: else:
......
...@@ -261,8 +261,8 @@ def generatePortalTypeClass(site, portal_type_name): ...@@ -261,8 +261,8 @@ def generatePortalTypeClass(site, portal_type_name):
accessor_holder_list = [] accessor_holder_list = []
if portal_type_name not in property_sheet_generating_portal_type_set: if portal_type_name not in property_sheet_generating_portal_type_set:
# LOG("ERP5Type.dynamic", INFO, LOG("ERP5Type.dynamic", INFO,
# "Filling accessor holder list for portal_type " + portal_type_name) "Filling accessor holder list for portal_type " + portal_type_name)
property_sheet_generating_portal_type_set.add(portal_type_name) property_sheet_generating_portal_type_set.add(portal_type_name)
try: try:
...@@ -383,7 +383,8 @@ def synchronizeDynamicModules(context, force=False): ...@@ -383,7 +383,8 @@ def synchronizeDynamicModules(context, force=False):
and send out an invalidation to other nodes and send out an invalidation to other nodes
""" """
portal = context.getPortalObject() portal = context.getPortalObject()
from zLOG import LOG
LOG("AUREL", 300, "syncDynamicModule")
global last_sync global last_sync
if force: if force:
# hard invalidation to force sync between nodes # hard invalidation to force sync between nodes
...@@ -426,6 +427,7 @@ def synchronizeDynamicModules(context, force=False): ...@@ -426,6 +427,7 @@ def synchronizeDynamicModules(context, force=False):
# some changes that are required for the migration. # some changes that are required for the migration.
if portal.id not in _bootstrapped and \ if portal.id not in _bootstrapped and \
TransactionalResource.registerOnce(__name__, 'bootstrap', portal.id): TransactionalResource.registerOnce(__name__, 'bootstrap', portal.id):
LOG("AUREL", 300, "will check for migration")
migrate = False migrate = False
from Products.ERP5Type.Tool.PropertySheetTool import PropertySheetTool from Products.ERP5Type.Tool.PropertySheetTool import PropertySheetTool
from Products.ERP5Type.Tool.TypesTool import TypesTool from Products.ERP5Type.Tool.TypesTool import TypesTool
...@@ -438,7 +440,7 @@ def synchronizeDynamicModules(context, force=False): ...@@ -438,7 +440,7 @@ def synchronizeDynamicModules(context, force=False):
# (only likely to happen on the first run ever) # (only likely to happen on the first run ever)
tool_id = tool_class.id tool_id = tool_class.id
tool = getattr(portal, tool_id, None) tool = getattr(portal, tool_id, None)
LOG("tool", 300, "%r"%(tool,))
if tool is None: if tool is None:
if tool_class == ERP5CatalogTool: if tool_class == ERP5CatalogTool:
# Wait till we find that SQL Catalog Tool is installed # Wait till we find that SQL Catalog Tool is installed
...@@ -467,7 +469,7 @@ def synchronizeDynamicModules(context, force=False): ...@@ -467,7 +469,7 @@ def synchronizeDynamicModules(context, force=False):
portal.portal_activities.initialize() portal.portal_activities.initialize()
except AttributeError: except AttributeError:
pass # no Activity Tool yet pass # no Activity Tool yet
LOG("AUREL", 300, "fix MembershipTool")
from Products.CMFCore.MembershipTool import MembershipTool from Products.CMFCore.MembershipTool import MembershipTool
tool = getattr(portal, "portal_membership", None) tool = getattr(portal, "portal_membership", None)
if tool and tool.__class__ is not MembershipTool: if tool and tool.__class__ is not MembershipTool:
......
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