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:
parent
330f15e634
commit
ab4442fb03
3 changed files with 46 additions and 4 deletions
|
@ -108,6 +108,10 @@ class IConcept(IConceptSchema, ILoopsObject, IPotentialTarget):
|
||||||
""" Return a concept that provides the object's type.
|
""" 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):
|
def getChildren(predicates=None):
|
||||||
""" Return a sequence of concepts related to self as child concepts,
|
""" Return a sequence of concepts related to self as child concepts,
|
||||||
optionally restricted to the predicates given.
|
optionally restricted to the predicates given.
|
||||||
|
|
|
@ -42,16 +42,19 @@ class LayoutNode(Node):
|
||||||
|
|
||||||
class NodeLayoutInstance(LayoutInstance):
|
class NodeLayoutInstance(LayoutInstance):
|
||||||
|
|
||||||
|
@Lazy
|
||||||
|
def target(self):
|
||||||
|
return adapted(self.context.target)
|
||||||
|
|
||||||
@Lazy
|
@Lazy
|
||||||
def targetView(self):
|
def targetView(self):
|
||||||
request = self.view.request
|
request = self.view.request
|
||||||
target = adapted(self.context.target)
|
view = component.getMultiAdapter((self.target, request), name='layout')
|
||||||
view = component.getMultiAdapter((target, request), name='layout')
|
|
||||||
view.node = self.context
|
view.node = self.context
|
||||||
return view
|
return view
|
||||||
|
|
||||||
|
|
||||||
class NavigationNodeLayoutInstance(NodeLayoutInstance):
|
class NavigationLayoutInstance(NodeLayoutInstance):
|
||||||
|
|
||||||
def getLayouts(self, region):
|
def getLayouts(self, region):
|
||||||
""" Return sublayout instances specified via subnodes of the current menu node.
|
""" Return sublayout instances specified via subnodes of the current menu node.
|
||||||
|
@ -70,3 +73,33 @@ class NavigationNodeLayoutInstance(NodeLayoutInstance):
|
||||||
li.template = layout
|
li.template = layout
|
||||||
result.append(li)
|
result.append(li)
|
||||||
return result
|
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
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,12 @@
|
||||||
<zope:adapter
|
<zope:adapter
|
||||||
for="loops.layout.interfaces.ILayoutNode"
|
for="loops.layout.interfaces.ILayoutNode"
|
||||||
name="navigation"
|
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" />
|
<include package=".browser" />
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue