diff --git a/external/base.py b/external/base.py index 7f7f2db..eb8d3d4 100644 --- a/external/base.py +++ b/external/base.py @@ -195,11 +195,9 @@ class Extractor(Base): #data = instance.applyTemplate(mode='export') data = instance.applyTemplate(mode='edit') noexp = getattr(aObj, '_noexportAttributes', ()) - for attr in noexp: + for attr in tuple(noexp) + ('title', 'name'): if attr in data: del data[attr] - if 'title' in data: - del data['title'] data['description'] = obj.description if not data['description']: del data['description'] diff --git a/interfaces.py b/interfaces.py index 24eb26a..8fe2811 100644 --- a/interfaces.py +++ b/interfaces.py @@ -427,6 +427,19 @@ class IBaseNode(IOrderedContainer): """ Return the loops root object. """ + def getParentNode(nodeTypes=None): + """ Return the next node up the node hierarchy. If the nodeTypes + parameter is given, search for the next node that has one of + the types in the nodeTypes list. + + Return None if no suitable node can be found. + """ + + def getChildNodes(nodeTypes=None): + """ Return a sequence of nodes contained in this node. If the + nodeTypes parameter is given return only nodes of these types. + """ + class INodeSchema(IView): @@ -456,19 +469,6 @@ class INode(INodeSchema, IBaseNode): """ contains(IView) - def getParentNode(nodeTypes=None): - """ Return the next node up the node hierarchy. If the nodeTypes - parameter is given, search for the next node that has one of - the types in the nodeTypes list. - - Return None if no suitable node can be found. - """ - - def getChildNodes(nodeTypes=None): - """ Return a sequence of nodes contained in this node. If the - nodeTypes parameter is given return only nodes of these types. - """ - def getMenu(): """ Return the menu node this node belongs to or None if not found. """ @@ -501,7 +501,8 @@ class INodeAdapter(Interface): """ -class IViewManager(ILoopsObject, IBaseNode): +#class IViewManager(ILoopsObject, IBaseNode): +class IViewManager(ILoopsObject, IOrderedContainer): """ A manager/container for views. """ contains(IView) diff --git a/layout/base.py b/layout/base.py index e3d1b9a..e4a51da 100644 --- a/layout/base.py +++ b/layout/base.py @@ -22,9 +22,12 @@ Layout node + instance implementations. $Id$ """ +from zope.cachedescriptors.property import Lazy from zope.interface import implements -from cybertools.composer.layout.base import LayoutInstance +from cybertools.composer.layout.base import Layout, LayoutInstance +from cybertools.composer.layout.interfaces import ILayoutInstance +from loops.layout.browser import ConceptView from loops.layout.interfaces import ILayoutNode, ILayoutNodeContained from loops.view import Node @@ -34,6 +37,38 @@ class LayoutNode(Node): implements(ILayoutNode, ILayoutNodeContained) +# layout instances + class NodeLayoutInstance(LayoutInstance): - pass + def getLayouts(self, region): + """ Return sublayout instances. + """ + if region is None: + return [] + result = [] + sublayouts = self.template.sublayouts + if sublayouts is not None: # hard-coded sublayouts + for l in region.layouts: + if sublayouts is None or l.name in sublayouts: + li = ILayoutInstance(self.context) + li.template = l + result.append(li) + return result + # sublayouts specified via subnodes + subnodes = self.context.values() + names = region.layouts.keys() + for n in subnodes: + if n.viewName in names: + layout = region.layouts[n.viewName] + li = ILayoutInstance(n) + li.template = layout + result.append(li) + # if not result: get layouts from parent node(s) + return result + + @Lazy + def targetView(self): + request = self.view.request + return ConceptView(self.context.target, request, self.context) + diff --git a/layout/browser.py b/layout/browser.py index 1a50c19..f8e7b2a 100644 --- a/layout/browser.py +++ b/layout/browser.py @@ -23,8 +23,10 @@ $Id$ """ from zope.cachedescriptors.property import Lazy +from zope.traversing.browser import absoluteURL from cybertools.composer.layout.browser.view import Page +from loops.browser.common import BaseView class LayoutNodeView(Page): @@ -32,3 +34,36 @@ class LayoutNodeView(Page): @Lazy def layoutName(self): return self.context.viewName or 'page' + + @Lazy + def layoutNames(self): + result = [] + n = self.context + while n is not None: + if n.viewName: + result.append(n.viewName) + n = n.getParentNode() + result.append('page') + return result + + +class ConceptView(object): + + def __init__(self, context, request, node=None): + self.context = context + self.request = request + self.node = node + + @Lazy + def title(self): + return self.context.title + + @Lazy + def url(self): + return absoluteURL(self.node, self.request) + + @property + def children(self): + for c in self.context.getChildren(): + yield ConceptView(c, self.request, self.node) + diff --git a/layout/configure.zcml b/layout/configure.zcml index bdf6eaa..4ab78ff 100644 --- a/layout/configure.zcml +++ b/layout/configure.zcml @@ -26,8 +26,7 @@ name="index.html" for="loops.layout.interfaces.ILayoutNode" class="loops.layout.browser.LayoutNodeView" - permission="zope.View" - /> + permission="zope.View" /> + view="AddLoopsLayoutNode.html" />