From dbc720c54a6f6c80304d69359a4c124ac6e41c45 Mon Sep 17 00:00:00 2001 From: Helmut Merz Date: Fri, 27 Apr 2012 12:18:38 +0200 Subject: [PATCH] work in progress: page layout for 'book' compound objects --- browser/lobo/configure.zcml | 22 +++++++++++----------- browser/lobo/standard.py | 2 +- compound/README.txt | 13 +++++++++++-- compound/base.py | 27 +++++++++++++++------------ compound/book/loops_book_de.dmp | 29 ++++++++++++++++++++++------- compound/interfaces.py | 6 ++---- compound/tests.py | 3 ++- configure.zcml | 2 +- 8 files changed, 65 insertions(+), 39 deletions(-) diff --git a/browser/lobo/configure.zcml b/browser/lobo/configure.zcml index 5bf7ea0..f8a145c 100644 --- a/browser/lobo/configure.zcml +++ b/browser/lobo/configure.zcml @@ -17,7 +17,7 @@ >> 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 ============= diff --git a/compound/base.py b/compound/base.py index 47bd907..8aec311 100644 --- a/compound/base.py +++ b/compound/base.py @@ -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] diff --git a/compound/book/loops_book_de.dmp b/compound/book/loops_book_de.dmp index db58c68..886aa88 100644 --- a/compound/book/loops_book_de.dmp +++ b/compound/book/loops_book_de.dmp @@ -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') diff --git a/compound/interfaces.py b/compound/interfaces.py index 4027d1e..0a3376b 100644 --- a/compound/interfaces.py +++ b/compound/interfaces.py @@ -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): diff --git a/compound/tests.py b/compound/tests.py index 644d326..f0f28ba 100755 --- a/compound/tests.py +++ b/compound/tests.py @@ -1,4 +1,5 @@ -# $Id$ +# tests.py +# Package loops.compound import unittest, doctest from zope.testing.doctestunit import DocFileSuite diff --git a/configure.zcml b/configure.zcml index 1692294..013d4ce 100644 --- a/configure.zcml +++ b/configure.zcml @@ -480,6 +480,7 @@ + @@ -492,7 +493,6 @@ -