diff --git a/layout/base.py b/layout/base.py
index a7c46f0..802bdea 100644
--- a/layout/base.py
+++ b/layout/base.py
@@ -35,6 +35,8 @@ from loops.view import Node
class LayoutNode(Node):
+ pageName = u''
+
implements(ILayoutNode, ILayoutNodeContained)
@@ -42,6 +44,10 @@ class LayoutNode(Node):
class NodeLayoutInstance(LayoutInstance):
+ @Lazy
+ def viewAnnotations(self):
+ return self.view.request.annotations.get('loops.view', {})
+
@Lazy
def target(self):
return adapted(self.context.target)
@@ -81,6 +87,7 @@ class TargetLayoutInstance(NodeLayoutInstance):
""" Return sublayout instances specified by the target object.
"""
target = self.target
+ pageName = self.viewAnnotations.get('pageName', u'')
if region is None or target is None:
return []
result = []
@@ -88,17 +95,20 @@ class TargetLayoutInstance(NodeLayoutInstance):
tp = target.context.conceptType
for n in tp.getClients():
if n.nodeType == 'info' and n.viewName in names:
+ if pageName != n.pageName:
+ continue
layout = region.layouts[n.viewName]
li = component.getAdapter(n, ILayoutInstance,
name=layout.instanceName)
li.template = layout
result.append(li)
+ # TODO: if not result: provide error info with names, pageName,
+ # info on client nodes
return result
@Lazy
def target(self):
- viewAnnotations = self.view.request.annotations.get('loops.view', {})
- target = viewAnnotations.get('target')
+ target = self.viewAnnotations.get('target')
if target is None:
target = adapted(self.context.target)
return target
diff --git a/layout/browser/configure.zcml b/layout/browser/configure.zcml
index e67cc55..43563de 100644
--- a/layout/browser/configure.zcml
+++ b/layout/browser/configure.zcml
@@ -18,11 +18,11 @@
name="AddLoopsLayoutNode.html"
content_factory="loops.layout.base.LayoutNode"
schema="loops.layout.interfaces.ILayoutNode"
- fields="title description nodeType viewName body"
+ fields="title description nodeType viewName pageName body"
template="../../browser/add.pt"
permission="zope.ManageContent">
-
+
+
+
+
+
+
1:
if '-' in name:
@@ -54,5 +56,9 @@ class NodeTraverser(ItemTraverser):
viewAnnotations['target'] = target
#return target
return self.context
- obj = super(NodeTraverser, self).publishTraverse(request, name)
+ try:
+ obj = super(NodeTraverser, self).publishTraverse(request, name)
+ except NotFound, e:
+ viewAnnotations['pageName'] = name
+ return self.context
return obj
diff --git a/layout/interfaces.py b/layout/interfaces.py
index a41ac07..325b939 100644
--- a/layout/interfaces.py
+++ b/layout/interfaces.py
@@ -24,6 +24,7 @@ $Id$
from zope.app.container.constraints import contains, containers
from zope.interface import Interface
+from zope import schema
from loops.interfaces import INodeSchema, IBaseNode, INode, IViewManager
@@ -33,6 +34,13 @@ class ILayoutView(INodeSchema):
presentation mechanism.
"""
+ pageName = schema.TextLine(
+ title=_(u'Page name'),
+ description=_(u'Name that may be used to identify the layout '
+ u'via a name in the URL.'),
+ default=u'',
+ required=False)
+
class ILayoutNode(ILayoutView, INode):
diff --git a/version.py b/version.py
index 0e7a088..8b21d39 100644
--- a/version.py
+++ b/version.py
@@ -21,7 +21,7 @@ loops version specifications.
"""
revision = '$Id$'
-shortVersion = '0.8'
+shortVersion = '0.9'
longVersion = '%s-%s' % (shortVersion, ' '.join(revision.split()[2:5]))
versions = dict(loops=shortVersion)