Commit e177f02f authored by Bryton Lacquement's avatar Bryton Lacquement 🚪

wip

parent 6ff0893f
......@@ -2049,7 +2049,7 @@ class RegisteredSkinSelectionTemplateItem(BaseTemplateItem):
update_dict = kw.get('object_to_update')
force = kw.get('force')
portal = context.getPortalObject()
skin_tool = getToolByName(portal, 'portal_skins')
skin_tool = portal.portal_skins
for skin_folder_id in self._objects.keys():
......
......@@ -322,7 +322,7 @@ class ERP5Site(FolderMixIn, CMFSite, CacheCookieMixin):
from Products.Localizer.MessageCatalog import (
message_catalog_alias_sources
)
sm = self.getSiteManager()
sm = self._components
for message_catalog in self.Localizer.objectValues():
sm.registerUtility(message_catalog,
provided=ITranslationDomain,
......@@ -332,21 +332,25 @@ class ERP5Site(FolderMixIn, CMFSite, CacheCookieMixin):
provided=ITranslationDomain,
name=alias)
def _doInitialSiteManagerMigration(self):
self._createInitialSiteManager()
# Now that we have a sitemanager, se can do things that require
# one. Including setting up ZTK style utilities and adapters. We
# can even call setSite(self), as long as we roll back that later,
# since we are actually in the middle of a setSite() call.
from zope.site.hooks import getSite, setSite
old_site = getSite()
try:
setSite(self)
# setSite(self) is not really necessary for the migration below, but
# could be needed by other migrations to be added here.
self._doTranslationDomainRegistration()
finally:
setSite(old_site)
def _registerMissingTools(self):
from Products.CMFCore import interfaces, utils
sm = self._components
for tool_id, tool_interface in utils._tool_interface_registry.iteritems():
if tool_interface not in (
interfaces.ISkinsTool,
interfaces.ITypesTool,
interfaces.IMembershipTool,
interfaces.IURLTool,
interfaces.IWorkflowTool,
): continue
# XXX: need to find the proper API to access "self.tool_id"
tool = getattr(self, tool_id, None)
if tool is not None:
# Note: already registered tools will be either:
# - updated
# - registered again after being unregistered
sm.registerUtility(aq_base(tool), tool_interface)
# backward compatibility auto-migration
def getSiteManager(self):
......@@ -364,13 +368,25 @@ class ERP5Site(FolderMixIn, CMFSite, CacheCookieMixin):
# as cheap as it is on the case that self._components is already
# set.
_components = self._components
if _components is not None:
return _components
# This method below can take as (reasonably) long as it pleases
# since it will not be run ever again
self._doInitialSiteManagerMigration()
assert self._components is not None, 'Migration Failed!'
return self._components
if _components is None:
# only create _components
self._createInitialSiteManager()
_components = self._components
# Now that we have a sitemanager, se can do things that require
# one. Including setting up ZTK style utilities and adapters. We
# can even call setSite(self), as long as we roll back that later,
# since we are actually in the middle of a setSite() call.
from zope.site.hooks import getSite, setSite
old_site = getSite()
try:
setSite(self)
self._doTranslationDomainRegistration()
self._registerMissingTools()
finally:
setSite(old_site)
else:
self._registerMissingTools()
return _components
security.declareProtected(Permissions.View, 'view')
def view(self):
......
......@@ -642,8 +642,8 @@ class TestProxyField(ERP5TypeTestCase):
ERP5Form('Base_viewProxyFieldLibrary', 'Proxys'))
self.container._setObject('Base_view',
ERP5Form('Base_view', 'View'))
from Products.CMFCore.tests.base.utils import _setUpDefaultTraversable
_setUpDefaultTraversable()
# from Products.CMFCore.tests.base.utils import _setUpDefaultTraversable
# _setUpDefaultTraversable()
def addField(self, form, id, title, field_type):
......
......@@ -141,11 +141,9 @@ def CMFCoreSkinnableSkinnableObjectManager_changeSkin(self, skinname, REQUEST=No
Patched not to call getSkin.
'''
if skinname is None:
sfn = self.getSkinsFolderName()
if sfn is not None:
sf = getattr(self, sfn, None)
if sf is not None:
skinname = sf.getDefaultSkin()
sf = getattr(self, "portal_skins", None)
if sf is not None:
skinname = sf.getDefaultSkin()
tid = get_ident()
SKINDATA[tid] = (
None,
......
......@@ -979,4 +979,15 @@ def canDoActionFor(self, ob, action, wf_id=None, guard_kw={}):
WorkflowTool.canDoActionFor = canDoActionFor
security.declarePrivate('_listTypeInfo')
def _listTypeInfo(self):
""" List the portal types which are available.
"""
ttool = getattr(self.getPortalObject(), "portal_types", None)
if ttool is not None:
return ttool.listTypeInfo()
return ()
WorkflowTool._listTypeInfo = _listTypeInfo
InitializeClass(WorkflowTool)
......@@ -20,8 +20,7 @@ from OFS.DTMLMethod import DTMLMethod
from OFS.Folder import Folder
from AccessControl.User import UserFolder
from Products.CMFCore.CookieCrumbler \
import CookieCrumbler, manage_addCC, Redirect
from Products.CMFCore.CookieCrumbler import CookieCrumbler, manage_addCC
from Products.CMFCore.tests.test_CookieCrumbler import makerequest
from Products.CMFCore.tests.test_CookieCrumbler import CookieCrumblerTests
......
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