work in progress: page layout for 'book' compound objects

This commit is contained in:
Helmut Merz 2012-04-27 12:18:38 +02:00
parent c74af2b960
commit dbc720c54a
8 changed files with 65 additions and 39 deletions

View file

@ -17,7 +17,7 @@
<zope:adapter
name="lobo_g3"
for="loops.interfaces.IConcept
for="loops.interfaces.IConceptSchema
loops.browser.skin.Lobo"
provides="zope.interface.Interface"
factory="loops.browser.lobo.standard.Grid3"
@ -25,7 +25,7 @@
<zope:adapter
name="lobo_lt"
for="loops.interfaces.IConcept
for="loops.interfaces.IConceptSchema
loops.browser.skin.Lobo"
provides="zope.interface.Interface"
factory="loops.browser.lobo.standard.ListThumbs"
@ -33,7 +33,7 @@
<zope:adapter
name="lobo_l1"
for="loops.interfaces.IConcept
for="loops.interfaces.IConceptSchema
loops.browser.skin.Lobo"
provides="zope.interface.Interface"
factory="loops.browser.lobo.standard.List1"
@ -41,7 +41,7 @@
<zope:adapter
name="lobo_l3"
for="loops.interfaces.IConcept
for="loops.interfaces.IConceptSchema
loops.browser.skin.Lobo"
provides="zope.interface.Interface"
factory="loops.browser.lobo.standard.List3"
@ -49,7 +49,7 @@
<zope:adapter
name="lobo_l2"
for="loops.interfaces.IConcept
for="loops.interfaces.IConceptSchema
loops.browser.skin.Lobo"
provides="zope.interface.Interface"
factory="loops.browser.lobo.standard.List2"
@ -57,7 +57,7 @@
<zope:adapter
name="lobo_ht"
for="loops.interfaces.IConcept
for="loops.interfaces.IConceptSchema
loops.browser.skin.Lobo"
provides="zope.interface.Interface"
factory="loops.browser.lobo.standard.HeaderThumbs"
@ -65,7 +65,7 @@
<zope:adapter
name="lobo_h0"
for="loops.interfaces.IConcept
for="loops.interfaces.IConceptSchema
loops.browser.skin.Lobo"
provides="zope.interface.Interface"
factory="loops.browser.lobo.standard.Header0"
@ -73,7 +73,7 @@
<zope:adapter
name="lobo_h1"
for="loops.interfaces.IConcept
for="loops.interfaces.IConceptSchema
loops.browser.skin.Lobo"
provides="zope.interface.Interface"
factory="loops.browser.lobo.standard.Header1"
@ -81,7 +81,7 @@
<zope:adapter
name="lobo_h2"
for="loops.interfaces.IConcept
for="loops.interfaces.IConceptSchema
loops.browser.skin.Lobo"
provides="zope.interface.Interface"
factory="loops.browser.lobo.standard.Header2"
@ -89,7 +89,7 @@
<zope:adapter
name="lobo_h3"
for="loops.interfaces.IConcept
for="loops.interfaces.IConceptSchema
loops.browser.skin.Lobo"
provides="zope.interface.Interface"
factory="loops.browser.lobo.standard.Header3"
@ -107,7 +107,7 @@
<zope:adapter
name="lobo_ig3"
for="loops.interfaces.IConcept
for="loops.interfaces.IConceptSchema
loops.browser.skin.Lobo"
provides="zope.interface.Interface"
factory="loops.browser.lobo.standard.ImageGrid3"

View file

@ -165,7 +165,7 @@ class Layout(Base, ConceptView):
result = []
for p in parts:
viewName = 'lobo_' + p
view = component.queryMultiAdapter((self.context, self.request),
view = component.queryMultiAdapter((self.adapted, self.request),
name=viewName)
if view is not None:
view.parent = self

View file

@ -2,8 +2,6 @@
loops - Linked Objects for Organization and Processing Services
===============================================================
($Id$)
>>> from zope import component
>>> from zope.traversing.api import getName
@ -349,6 +347,17 @@ Micro Articles
u'Systemic KM talks about organizational knowledge.'
Books, Sections, and Pages
==========================
>>> import os
>>> from loops.setup import importData
>>> importPath = os.path.join(os.path.dirname(__file__), 'book')
>>> importData(loopsRoot, importPath, 'loops_book_de.dmp')
>>> from loops.compound.book.browser import PageLayout
Fin de partie
=============

View file

@ -1,5 +1,5 @@
#
# Copyright (c) 2008 Helmut Merz helmutm@cy55.de
# Copyright (c) 2012 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
@ -18,8 +18,6 @@
"""
Compound objects like articles, blog posts, storyboard items, ...
$Id$
"""
from zope.cachedescriptors.property import Lazy
@ -27,35 +25,40 @@ from zope.interface import implements
from zope.traversing.api import getName
from loops.common import AdapterBase
from loops.compound.interfaces import ICompound, compoundPredicateName
from loops.compound.interfaces import ICompound, compoundPredicateNames
class Compound(AdapterBase):
implements(ICompound)
compoundPredicateNames = compoundPredicateNames
@Lazy
def compoundPredicate(self):
return self.context.getConceptManager()[compoundPredicateName]
def compoundPredicates(self):
return [self.context.getConceptManager()[n]
for n in self.compoundPredicateNames]
def getParts(self):
if self.context.__parent__ is None:
return []
return self.context.getResources([self.partOf])
return self.context.getResources(self.compoundPredicates)
def add(self, obj, position=None):
if position is None:
order = self.getMaxOrder() + 1
else:
order = self.getOrderForPosition(position)
self.context.assignResource(obj, self.partOf, order=order)
self.context.assignResource(obj, self.partOf,
order=order)
def remove(self, obj, position=None):
if position is None:
self.context.deassignResource(obj, [self.partOf])
self.context.deassignResource(obj, self.compoundPredicates)
else:
rel = self.getPartRelations()[position]
self.context.deassignResource(obj, [self.partOf], order=rel.order)
self.context.deassignResource(obj, self.compoundPredicates,
order=rel.order)
def reorder(self, parts):
existing = list(self.getPartRelations())
@ -77,7 +80,7 @@ class Compound(AdapterBase):
# helper methods and properties
def getPartRelations(self):
return self.context.getResourceRelations([self.partOf])
return self.context.getResourceRelations(self.compoundPredicates)
def getMaxOrder(self):
rels = self. getPartRelations()
@ -117,5 +120,5 @@ class Compound(AdapterBase):
@Lazy
def partOf(self):
return self.conceptManager[compoundPredicateName]
return self.compoundPredicates[0]

View file

@ -1,16 +1,31 @@
type(u'documenttype', u'Dokumentenart', options=u'qualifier:assign',
viewName=u'')
# book types
type(u'book', u'Buch', viewName=u'', typeInterface=u'',
options=u'action.portlet:create_subtype,edit_concept')
type(u'page', u'Seite', viewName=u'', typeInterface=u'',
type(u'page', u'Seite', viewName=u'page_layout',
typeInterface=u'loops.compound.book.interfaces.IPage',
options=u'action.portlet:edit_concept')
type(u'section', u'Kapitel', viewName=u'', typeInterface=u'',
options=u'action.portlet:create_subtype,edit_concept')
concept(u'ispartof', u'is Part of', u'predicate', options=u'', predicateInterface=u'')
concept(u'issubtype', u'is Subtype', u'predicate', options=u'', predicateInterface=u'')
concept(u'system', u'System', u'domain')
# predicates
concept(u'ispartof', u'is Part of', u'predicate', options=u'',
predicateInterface=u'')
concept(u'issubtype', u'is Subtype', u'predicate', options=u'hide_children',
predicateInterface='loops.interfaces.IIsSubtype')
# document types
concept(u'keyquestions', u'Leitfragen', u'documenttype')
concept(u'maintext', u'Haupttext', u'documenttype')
concept(u'quote', u'Zitat', u'documenttype')
concept(u'story', u'Geschichte', u'documenttype')
concept(u'usecase', u'Fallbeispiel', u'documenttype')
child(u'book', u'section', u'issubtype')
child(u'section', u'section', u'issubtype')
child(u'section', u'page', u'issubtype')
child(u'system', u'personal_info', u'standard')
# book structure
child(u'book', u'section', u'issubtype', usePredicate=u'ispartof')
child(u'section', u'section', u'issubtype', usePredicate=u'ispartof')
child(u'section', u'page', u'issubtype', usePredicate=u'ispartof')

View file

@ -1,5 +1,5 @@
#
# Copyright (c) 2008 Helmut Merz helmutm@cy55.de
# Copyright (c) 2012 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
@ -18,8 +18,6 @@
"""
Compound objects like articles, blog posts, storyboard items, ...
$Id$
"""
#TODO: move generic stuff to cybertools.composer
@ -31,7 +29,7 @@ from loops.interfaces import IConceptSchema
from loops.util import _
compoundPredicateName = 'ispartof'
compoundPredicateNames = ['ispartof']
class ICompound(IConceptSchema):

View file

@ -1,4 +1,5 @@
# $Id$
# tests.py
# Package loops.compound
import unittest, doctest
from zope.testing.doctestunit import DocFileSuite

View file

@ -480,6 +480,7 @@
<include package=".browser" />
<include package=".classifier" />
<include package=".compound.blog" />
<include package=".compound.book" />
<include package=".compound.microart" />
<include package=".config" />
<include package=".constraint" />
@ -492,7 +493,6 @@
<include package=".media" />
<include package=".organize" />
<include package=".rest" />
<!--<include package=".search" />-->
<include package=".security" />
<include package=".system" />
<include package=".versioning" />