new target layout instance, controlled by client node(s)

git-svn-id: svn://svn.cy55.de/Zope3/src/loops/trunk@2995 fd906abe-77d9-0310-91a1-e0d9ade77398
This commit is contained in:
helmutm 2008-11-17 11:54:47 +00:00
parent 330f15e634
commit ab4442fb03
3 changed files with 46 additions and 4 deletions

View file

@ -108,6 +108,10 @@ class IConcept(IConceptSchema, ILoopsObject, IPotentialTarget):
""" Return a concept that provides the object's type.
"""
def getClients(relationships=None):
""" Return a sequence of objects that the concept is the target of.
"""
def getChildren(predicates=None):
""" Return a sequence of concepts related to self as child concepts,
optionally restricted to the predicates given.

View file

@ -42,16 +42,19 @@ class LayoutNode(Node):
class NodeLayoutInstance(LayoutInstance):
@Lazy
def target(self):
return adapted(self.context.target)
@Lazy
def targetView(self):
request = self.view.request
target = adapted(self.context.target)
view = component.getMultiAdapter((target, request), name='layout')
view = component.getMultiAdapter((self.target, request), name='layout')
view.node = self.context
return view
class NavigationNodeLayoutInstance(NodeLayoutInstance):
class NavigationLayoutInstance(NodeLayoutInstance):
def getLayouts(self, region):
""" Return sublayout instances specified via subnodes of the current menu node.
@ -70,3 +73,33 @@ class NavigationNodeLayoutInstance(NodeLayoutInstance):
li.template = layout
result.append(li)
return result
class TargetLayoutInstance(NodeLayoutInstance):
def getLayouts(self, region):
""" Return sublayout instances specified by the target object.
"""
target = self.target
if region is None or target is None:
return []
result = []
names = region.layouts.keys()
tp = target.context.conceptType
for n in tp.getClients():
if n.nodeType == 'info' and n.viewName in names:
layout = region.layouts[n.viewName]
li = component.getAdapter(n, ILayoutInstance,
name=layout.instanceName)
li.template = layout
result.append(li)
return result
@Lazy
def target(self):
viewAnnotations = self.view.request.annotations.get('loops.view', {})
target = viewAnnotations.get('target')
if target is None:
target = adapted(self.context.target)
return target

View file

@ -23,7 +23,12 @@
<zope:adapter
for="loops.layout.interfaces.ILayoutNode"
name="navigation"
factory="loops.layout.base.NavigationNodeLayoutInstance" />
factory="loops.layout.base.NavigationLayoutInstance" />
<zope:adapter
for="loops.layout.interfaces.ILayoutNode"
name="target"
factory="loops.layout.base.TargetLayoutInstance" />
<include package=".browser" />