Commit 3e5c5c52 authored by Aurel's avatar Aurel

use queryUtility to look after the portal_membership

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