From d76c881c17cf7fcbd0214f1ab7f040e22cdc6f70 Mon Sep 17 00:00:00 2001 From: helmutm Date: Tue, 23 Feb 2010 13:15:39 +0000 Subject: [PATCH] do not use layouts within default root node if there are more specific layouts git-svn-id: svn://svn.cy55.de/Zope3/src/loops/trunk@3750 fd906abe-77d9-0310-91a1-e0d9ade77398 --- layout/base.py | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/layout/base.py b/layout/base.py index da47969..edc5d33 100644 --- a/layout/base.py +++ b/layout/base.py @@ -108,8 +108,10 @@ class TargetLayoutInstance(NodeLayoutInstance): pageName = self.viewAnnotations.get('pageName', u'') obj = self.target.context tp = obj.getType() - found = False + #found = False currentRoot = self.context.getMenu() + specifics = [] + defaults = [] for n in obj.getClients() + tp.getClients(): if not ILayoutNode.providedBy(n): continue @@ -117,15 +119,25 @@ class TargetLayoutInstance(NodeLayoutInstance): if pageName != (n.pageName or '').strip(): continue layoutRoot = n.getMenu() - if getName(layoutRoot) != 'default' and layoutRoot != currentRoot: + rootName = getName(layoutRoot) + if rootName != 'default' and layoutRoot != currentRoot: continue layout = region.layouts[n.viewName] li = component.getAdapter(n, ILayoutInstance, name=layout.instanceName) li.template = layout - result.append(li) - found = True - if not found: + #result.append(li) + #found = True + if rootName == 'default': + defaults.append(li) + else: + specifics.append(li) + if specifics: + result.extend(specifics) + elif defaults: + result.extend(defaults) + #if not found: + else: if self.template.defaultSublayout is None: logger.warn('No target layout found: pageName = %r, target = %r' % (pageName, getName(obj)))