Commit b8e153c6 authored by Romain Courteaud's avatar Romain Courteaud

[erp5_web] Remove the StaticWebSectionTraversalHook class

Defining it inside portal_components ledds to business template update issue.
Bypass it by defining the expected behaviour into the web section hook.
parent 5747f7be
...@@ -34,22 +34,11 @@ from OFS.Traversable import NotFound ...@@ -34,22 +34,11 @@ from OFS.Traversable import NotFound
from Products.ERP5.mixin.extensible_traversable import DocumentExtensibleTraversableMixin from Products.ERP5.mixin.extensible_traversable import DocumentExtensibleTraversableMixin
from Products.ERP5.Document.WebSection import WebSection from Products.ERP5.Document.WebSection import WebSection
from Products.ERP5Type import Permissions from Products.ERP5Type import Permissions
from Persistence import Persistent
from webdav.NullResource import NullResource from webdav.NullResource import NullResource
MARKER = [] MARKER = []
class StaticWebSectionTraversalHook(Persistent):
"""Traversal hook to change the skin selection for this websection.
"""
def __call__(self, container, request):
if not request.get('ignore_layout', None):
# If a skin selection is defined in this web section, change the skin now.
skin_selection_name = container.getSkinSelectionName()
if skin_selection_name:# and request.get('portal_skin', None) is None:
container.getPortalObject().changeSkin(skin_selection_name)
class StaticWebSection(WebSection): class StaticWebSection(WebSection):
""" """
This Web Section only get resource from the DMS. This Web Section only get resource from the DMS.
...@@ -60,11 +49,6 @@ class StaticWebSection(WebSection): ...@@ -60,11 +49,6 @@ class StaticWebSection(WebSection):
security = ClassSecurityInfo() security = ClassSecurityInfo()
security.declareObjectProtected(Permissions.AccessContentsInformation) security.declareObjectProtected(Permissions.AccessContentsInformation)
def _getTraversalHookClass(self):
return StaticWebSectionTraversalHook
_traversal_hook_class = StaticWebSectionTraversalHook
def getExtensibleContent(self, request, name): def getExtensibleContent(self, request, name):
stack = request['TraversalRequestNameStack'] stack = request['TraversalRequestNameStack']
......
...@@ -44,6 +44,7 @@ from Products.ERP5Type.Cache import getReadOnlyTransactionCache ...@@ -44,6 +44,7 @@ from Products.ERP5Type.Cache import getReadOnlyTransactionCache
# Global keys used for URL generation # Global keys used for URL generation
WEBSECTION_KEY = 'web_section_value' WEBSECTION_KEY = 'web_section_value'
MARKER = [] MARKER = []
WEB_SECTION_PORTAL_TYPE_TUPLE = ('Web Section', 'Web Site')
class WebSectionTraversalHook(Persistent): class WebSectionTraversalHook(Persistent):
"""Traversal hook to change the skin selection for this websection. """Traversal hook to change the skin selection for this websection.
...@@ -52,7 +53,9 @@ class WebSectionTraversalHook(Persistent): ...@@ -52,7 +53,9 @@ class WebSectionTraversalHook(Persistent):
if not request.get('ignore_layout', None): if not request.get('ignore_layout', None):
# If a skin selection is defined in this web section, change the skin now. # If a skin selection is defined in this web section, change the skin now.
skin_selection_name = container.getSkinSelectionName() skin_selection_name = container.getSkinSelectionName()
if skin_selection_name and request.get('portal_skin', None) is None: if skin_selection_name and \
((request.get('portal_skin', None) is None) or \
container.getPortalType() not in WEB_SECTION_PORTAL_TYPE_TUPLE):
container.getPortalObject().changeSkin(skin_selection_name) container.getPortalObject().changeSkin(skin_selection_name)
class WebSection(Domain, DocumentExtensibleTraversableMixin): class WebSection(Domain, DocumentExtensibleTraversableMixin):
...@@ -451,7 +454,7 @@ class WebSection(Domain, DocumentExtensibleTraversableMixin): ...@@ -451,7 +454,7 @@ class WebSection(Domain, DocumentExtensibleTraversableMixin):
def _edit(self, **kw): def _edit(self, **kw):
# XXX it is unclear if we should keep this behavior in other potential subclasses. # XXX it is unclear if we should keep this behavior in other potential subclasses.
# Probably yes. # Probably yes.
if self.getPortalType() in ('Web Section', 'Web Site'): if self.getPortalType() in WEB_SECTION_PORTAL_TYPE_TUPLE:
if getattr(self, '__before_traverse__', None) is None: if getattr(self, '__before_traverse__', None) is None:
# migrate beforeTraverse hook if missing # migrate beforeTraverse hook if missing
handle = self.meta_type + '/' + self.getId() handle = self.meta_type + '/' + self.getId()
......
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