Commit bd5e4c85 authored by Klaus Wölfel's avatar Klaus Wölfel Committed by Ivan Tyagov

Resolve all objects in portal_callables

parent fa172b02
...@@ -30,7 +30,7 @@ from Acquisition import aq_base ...@@ -30,7 +30,7 @@ from Acquisition import aq_base
during the same request. during the same request.
""" """
def _initializeCache(skin_tool, skin_folder_id_list): def _initializeCache(portal_callables, skin_tool, skin_folder_id_list):
skin_list = {} skin_list = {}
for skin_folder_id in skin_folder_id_list[::-1]: for skin_folder_id in skin_folder_id_list[::-1]:
try: try:
...@@ -40,6 +40,9 @@ def _initializeCache(skin_tool, skin_folder_id_list): ...@@ -40,6 +40,9 @@ def _initializeCache(skin_tool, skin_folder_id_list):
' but does not exist.' % skin_folder_id) ' but does not exist.' % skin_folder_id)
else: else:
skin_list.update(dict.fromkeys(skin_folder.objectIds(), skin_folder_id)) skin_list.update(dict.fromkeys(skin_folder.objectIds(), skin_folder_id))
# update skin_list with objects in portal_callables
if portal_callables is not None:
skin_list.update(dict.fromkeys(portal_callables.objectIds(), "portal_callables"))
return skin_list return skin_list
def CMFCoreSkinnableSkinnableObjectManager_initializeCache(self): def CMFCoreSkinnableSkinnableObjectManager_initializeCache(self):
...@@ -50,10 +53,13 @@ def CMFCoreSkinnableSkinnableObjectManager_initializeCache(self): ...@@ -50,10 +53,13 @@ def CMFCoreSkinnableSkinnableObjectManager_initializeCache(self):
if portal_skins is None: if portal_skins is None:
return return
portal_skins = portal_skins.aq_base portal_skins = portal_skins.aq_base
portal_callables = getattr(self, 'portal_callables', None)
if portal_callables is not None:
portal_callables = portal_callables.aq_base
skin_selection_mapping = {} skin_selection_mapping = {}
for selection_name, skin_folder_id_string in portal_skins._getSelections().iteritems(): for selection_name, skin_folder_id_string in portal_skins._getSelections().iteritems():
skin_selection_mapping[selection_name] = _initializeCache(portal_skins, skin_selection_mapping[selection_name] = _initializeCache(portal_callables,
skin_folder_id_string.split(',')) portal_skins, skin_folder_id_string.split(','))
portal_skins._v_skin_location_list = skin_selection_mapping portal_skins._v_skin_location_list = skin_selection_mapping
return skin_selection_mapping return skin_selection_mapping
...@@ -79,7 +85,8 @@ def skinResolve(self, selection, name): ...@@ -79,7 +85,8 @@ def skinResolve(self, selection, name):
if selection in skin_selection_mapping or \ if selection in skin_selection_mapping or \
isinstance(selection, basestring): isinstance(selection, basestring):
return return
skin_list = portal_skins._getSelections()[selection[0]].split(',') skin_list = portal_skins._getSelections()[selection[0]].split(',') \
+ ['portal_callables']
skin_selection_mapping[selection] = skin_list = _initializeCache( skin_selection_mapping[selection] = skin_list = _initializeCache(
portal_skins, skin_list[1+skin_list.index(selection[1]):]) portal_skins, skin_list[1+skin_list.index(selection[1]):])
try: try:
...@@ -88,6 +95,8 @@ def skinResolve(self, selection, name): ...@@ -88,6 +95,8 @@ def skinResolve(self, selection, name):
return return
reset = True reset = True
try: try:
if skin_folder_id == "portal_callables":
return aq_base(getattr(aq_base(self.portal_callables), name))
return aq_base(getattr(getattr(portal_skins, skin_folder_id), name)) return aq_base(getattr(getattr(portal_skins, skin_folder_id), name))
except AttributeError: except AttributeError:
if reset: if reset:
......
...@@ -59,7 +59,8 @@ def CMFCoreSkinsTool__updateCacheEntry(self, container_id, object_id): ...@@ -59,7 +59,8 @@ def CMFCoreSkinsTool__updateCacheEntry(self, container_id, object_id):
if not isinstance(selection_name, basestring): if not isinstance(selection_name, basestring):
del skin_location_list[selection_name] del skin_location_list[selection_name]
for selection_name, skin_folder_id_string in self._getSelections().iteritems(): for selection_name, skin_folder_id_string in self._getSelections().iteritems():
skin_folder_id_list = skin_folder_id_string.split(',') # Add portal_callables to every selection
skin_folder_id_list = skin_folder_id_string.split(',') + ['portal_callables']
if container_id in skin_folder_id_list: if container_id in skin_folder_id_list:
skin_folder_id_list.reverse() skin_folder_id_list.reverse()
this_folder_index = skin_folder_id_list.index(container_id) this_folder_index = skin_folder_id_list.index(container_id)
......
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