Set up basic machinery for views/nodes

git-svn-id: svn://svn.cy55.de/Zope3/src/loops/trunk@998 fd906abe-77d9-0310-91a1-e0d9ade77398
This commit is contained in:
helmutm 2006-01-10 14:43:44 +00:00
parent 535e2d3f3b
commit c2806a8c10
5 changed files with 135 additions and 23 deletions

View file

@ -3,8 +3,24 @@
<configure
xmlns:zope="http://namespaces.zope.org/zope"
xmlns="http://namespaces.zope.org/browser"
i18n_domain="zope"
>
i18n_domain="zope">
<!-- macros -->
<page
for="*"
name="loops_macros"
permission="zope.View"
class=".macros.Macros"
allowed_interface="zope.interface.common.mapping.IItemMapping"
/>
<page
for="*"
name="node_macros"
template="node.pt"
permission="zope.View"
/>
<!-- loops top-level container -->
@ -44,7 +60,7 @@
<containerViews
for="loops.interfaces.IConceptManager"
contents="zope.View"
contents="zope.ManageContent"
add="zope.ManageContent"
/>
@ -93,8 +109,7 @@
<pages
for="loops.interfaces.IConcept"
class=".concept.ConceptRelations"
permission="zope.ManageContent"
>
permission="zope.ManageContent">
<page
name="assign.html"
@ -129,7 +144,7 @@
<containerViews
for="loops.interfaces.IResourceManager"
contents="zope.View"
contents="zope.ManageContent"
add="zope.ManageContent"
/>
@ -182,26 +197,24 @@
<containerViews
for="loops.interfaces.IViewManager"
contents="zope.View"
contents="zope.ManageContent"
add="zope.ManageContent"
/>
<!-- node -->
<containerViews
for="loops.interfaces.INode"
contents="zope.View"
add="zope.ManageContent"
/>
<addform
label="Add Node"
name="AddLoopsNode.html"
content_factory="loops.view.Node"
schema="loops.interfaces.INode"
fields="title description"
permission="zope.ManageContent"
/>
fields="title description type body"
permission="zope.ManageContent">
<widget field="description" height="2" />
<widget field="body" height="4" />
</addform>
<addMenuItem
class="loops.view.Node"
@ -215,10 +228,32 @@
label="Edit Node"
name="edit.html"
schema="loops.interfaces.INode"
fields="title description"
fields="title description type body"
for="loops.interfaces.INode"
permission="zope.ManageContent"
menu="zmi_views" title="Edit"
menu="zmi_views" title="Edit">
<widget field="description" height="2" />
<widget field="body" height="4" />
</editform>
<page
name="node.html"
for="loops.interfaces.INode"
template="node.pt"
permission="zope.View"
/>
<defaultView
for="loops.interfaces.INode"
name="node.html"
/>
<containerViews
for="loops.interfaces.INode"
contents="zope.ManageContent"
add="zope.ManageContent"
/>
</configure>

28
browser/macros.py Normal file
View file

@ -0,0 +1,28 @@
#
# Copyright (c) 2006 Helmut Merz helmutm@cy55.de
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
"""
Macro definitions.
$Id$
"""
from zope.app.rotterdam.standardmacros import StandardMacros
class Macros(StandardMacros):
macro_pages = ('node_macros',)

24
browser/node.pt Normal file
View file

@ -0,0 +1,24 @@
<tal:show i18n:domain="loops">
<html metal:use-macro="context/@@skin_macros/page">
<head></head>
<body>
<metal:body fill-slot="body">
<tal:content define="item context;
level level|python: 1">
<metal:block define-macro="content">
<div tal:content="structure item/body">The body</div>
<div tal:define="level python:level+1">
<tal:items repeat="item item/values">
<metal:portlet use-macro="views/node_macros/content" />
</tal:items>
</div>
</metal:block>
</tal:content>
</metal:body>
</body>
</html>
</tal:show>

View file

@ -174,9 +174,26 @@ class IView(Interface):
class INode(IView, IOrderedContainer):
""" A node is a view that may contain other views, thus building a
menu or folder hierarchy.
A node may be a content object on its own; for this reason it
has a body attribute that may be shown e.g. on web pages.
"""
contains(IView)
type = schema.Choice(
title=_(u'Type'),
description=_(u'Type of the node'),
values=('page', 'text', 'menu', 'menuitem'),
default='page',
required=True)
body = schema.Text(
title=_(u'Body'),
description=_(u'Textual body that may be shown in addition to '
'or instead of information coming from the target'),
default=u'',
required=False)
class IViewManager(IContainer):
""" A manager/container for views.

14
view.py
View file

@ -78,11 +78,20 @@ class View(object):
super(View, self).__init__()
class Node(View, OrderedContainer):
implements(INode)
_type = 'page'
def getType(self): return self._type
def setType(self, type): self._type = type
type = property(getType, setType)
_body = u''
def getBody(self): return self._body
def setBody(self, body): self._body = body
body = property(getBody, setBody)
class ViewManager(BTreeContainer):
@ -90,7 +99,6 @@ class ViewManager(BTreeContainer):
class TargetRelation(DyadicRelation):
""" A relation between a view and a concept or resource object.
""" A relation between a view and another object.
"""