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

wip

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