diff --git a/layout/README.txt b/layout/README.txt
new file mode 100644
index 0000000..fa63f69
--- /dev/null
+++ b/layout/README.txt
@@ -0,0 +1,46 @@
+===============================================================
+loops - Linked Objects for Organization and Processing Services
+===============================================================
+
+Layout management.
+
+ ($Id$)
+
+
+Setting up a loops Site and Utilities
+=====================================
+
+Let's do some basic set up
+
+ >>> from zope import component, interface
+ >>> from zope.traversing.api import getName
+ >>> from zope.app.testing.setup import placefulSetUp, placefulTearDown
+ >>> site = placefulSetUp(True)
+
+and build a simple loops site with a concept manager and some concepts
+(with a relation registry, a catalog, and all the type machinery - what
+in real life is done via standard ZCML setup or via local utility
+configuration):
+
+ >>> from loops.integrator.testsetup import TestSite
+ >>> t = TestSite(site)
+ >>> concepts, resources, views = t.setup()
+ >>> loopsRoot = concepts.getLoopsRoot()
+
+ >>> from loops.layout.tests import setup
+ >>> setup()
+
+
+Defining Layouts
+================
+
+ >>> from loops.layout.base import LayoutNode
+
+ >>> demo = views['demo'] = LayoutNode('Demo Root Layout')
+ >>> demo.nodeType = 'menu'
+
+
+Fin de partie
+=============
+
+ >>> placefulTearDown()
diff --git a/layout/base.py b/layout/base.py
index 966dd37..e37ef24 100644
--- a/layout/base.py
+++ b/layout/base.py
@@ -23,6 +23,7 @@ $Id$
"""
from zope import component
+from zope.component import adapts
from zope.cachedescriptors.property import Lazy
from zope.interface import implements
@@ -44,6 +45,8 @@ class LayoutNode(Node):
class NodeLayoutInstance(LayoutInstance):
+ adapts(ILayoutNode)
+
@Lazy
def viewAnnotations(self):
return self.view.request.annotations.get('loops.view', {})
@@ -62,6 +65,8 @@ class NodeLayoutInstance(LayoutInstance):
class SubnodesLayoutInstance(NodeLayoutInstance):
+ adapts(ILayoutNode)
+
def getLayouts(self, region):
""" Return sublayout instances specified via subnodes of the current menu node.
"""
@@ -82,19 +87,24 @@ class SubnodesLayoutInstance(NodeLayoutInstance):
class TargetLayoutInstance(NodeLayoutInstance):
+ """ Associates a layout with all objects of a certain type.
+ """
+
+ adapts(ILayoutNode)
def getLayouts(self, region):
""" Return sublayout instances specified by the target object.
"""
- target = self.target
- if region is None or target is None:
+ if region is None or self.target is None:
return []
- #result = []
result = super(TargetLayoutInstance, self).getLayouts(region)
names = region.layouts.keys()
- tp = target.context.getType()
pageName = self.viewAnnotations.get('pageName', u'')
- for n in tp.getClients():
+ obj = self.target.context
+ tp = obj.getType()
+ for n in obj.getClients() + tp.getClients():
+ if not ILayoutNode.providedBy(n):
+ continue
if n.nodeType == 'info' and n.viewName in names:
if pageName != n.pageName:
continue
@@ -113,4 +123,3 @@ class TargetLayoutInstance(NodeLayoutInstance):
if target is None:
target = adapted(self.context.target)
return target
-
diff --git a/layout/browser/concept.py b/layout/browser/concept.py
index 764ac13..4f773eb 100644
--- a/layout/browser/concept.py
+++ b/layout/browser/concept.py
@@ -42,7 +42,8 @@ class ConceptView(BaseView):
def children(self):
for c in self.context.getChildren():
a = adapted(c)
- view = component.getMultiAdapter((c, self.request), name='layout')
+ #view = component.getMultiAdapter((c, self.request), name='layout')
+ view = component.getMultiAdapter((a, self.request), name='layout')
view.node = self.node
yield view
diff --git a/layout/configure.zcml b/layout/configure.zcml
index 9c4b8ee..5e642fc 100644
--- a/layout/configure.zcml
+++ b/layout/configure.zcml
@@ -17,16 +17,13 @@
diff --git a/layout/tests.py b/layout/tests.py
new file mode 100755
index 0000000..aff0363
--- /dev/null
+++ b/layout/tests.py
@@ -0,0 +1,31 @@
+# $Id$
+
+import unittest, doctest
+from zope.testing.doctestunit import DocFileSuite
+
+from zope import component
+from loops.layout.base import NodeLayoutInstance, SubnodesLayoutInstance
+from loops.layout.base import TargetLayoutInstance
+
+def setup():
+ component.provideAdapter(NodeLayoutInstance)
+ component.provideAdapter(SubnodesLayoutInstance, name='subnodes')
+ component.provideAdapter(TargetLayoutInstance, name='target')
+
+
+class Test(unittest.TestCase):
+ "Basic tests for the layout sub-package."
+
+ def testSomething(self):
+ pass
+
+
+def test_suite():
+ flags = doctest.NORMALIZE_WHITESPACE | doctest.ELLIPSIS
+ return unittest.TestSuite((
+ unittest.makeSuite(Test),
+ DocFileSuite('README.txt', optionflags=flags),
+ ))
+
+if __name__ == '__main__':
+ unittest.main(defaultTest='test_suite')