Merge branch 'master' into bbmaster

This commit is contained in:
Helmut Merz 2012-04-28 08:51:52 +02:00
commit 8adb6131e1
14 changed files with 342 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

@ -0,0 +1,2 @@
# __init__.py
# Package: loops.compound.book

52
compound/book/base.py Normal file
View file

@ -0,0 +1,52 @@
#
# 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
# 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
#
"""
Implementation of book and book components
"""
from zope.cachedescriptors.property import Lazy
from zope.interface import implements
from zope.traversing.api import getName
from loops.compound.base import Compound
from loops.compound.book.interfaces import IPage
from loops.type import TypeInterfaceSourceList
TypeInterfaceSourceList.typeInterfaces += (IPage,)
class Page(Compound):
implements(IPage)
compoundPredicateNames = ['ispartof', 'standard']
@Lazy
def documentType(self):
return self.context.getConceptManager()['documenttype']
def getParts(self):
result = {}
for r in super(Page, self).getParts():
for parent in r.getParents():
if parent.conceptType == self.documentType:
item = result.setdefault(getName(parent), [])
item.append(r)
return result

92
compound/book/browser.py Normal file
View file

@ -0,0 +1,92 @@
#
# 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
# 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
#
"""
View class(es) book/section/page structures.
"""
from cgi import parse_qs
from zope import interface, component
from zope.app.pagetemplate import ViewPageTemplateFile
from zope.cachedescriptors.property import Lazy
from cybertools.typology.interfaces import IType
from loops.browser.lobo import standard
from loops.browser.concept import ConceptRelationView as BaseConceptRelationView
from loops.browser.resource import ResourceView as BaseResourceView
from loops.common import adapted, baseObject
standard_template = standard.standard_template
book_template = ViewPageTemplateFile('view_macros.pt')
class PageLayout(standard.Layout):
def getParts(self):
parts = ['headline', 'keyquestions', 'quote', 'maintext',
'story', 'usecase']
return self.getPartViews(parts)
class PagePart(object):
template = book_template
templateName = 'compound.book'
macroName = 'text'
partName = None # define in subclass
gridPattern = ['span-4']
def getResources(self):
result = []
res = self.adapted.getParts().get(self.partName) or []
for idx, r in enumerate(res):
result.append(standard.ResourceView(
r, self.request, parent=self, idx=idx))
return result
class Headline(PagePart, standard.Header2):
macroName = 'headline'
class MainText(PagePart, standard.BasePart):
partName = 'maintext'
class KeyQuestions(PagePart, standard.BasePart):
partName = 'keyquestions'
class Story(PagePart, standard.BasePart):
partName = 'story'
class UseCase(PagePart, standard.BasePart):
partName = 'usecase'
class Quote(PagePart, standard.BasePart):
partName = 'quote'
gridPattern = ['span-2 last']

View file

@ -0,0 +1,78 @@
<configure
xmlns:zope="http://namespaces.zope.org/zope"
xmlns:browser="http://namespaces.zope.org/browser"
i18n_domain="loops">
<!-- type adapters -->
<zope:adapter factory="loops.compound.book.base.Page"
provides="loops.compound.book.interfaces.IPage"
trusted="True" />
<zope:class class="loops.compound.book.base.Page">
<require permission="zope.View"
interface="loops.compound.book.interfaces.IPage" />
<require permission="zope.ManageContent"
set_schema="loops.compound.book.interfaces.IPage" />
</zope:class>
<!-- Views -->
<zope:adapter
name="page_layout"
for="loops.interfaces.IConcept
loops.browser.skin.Lobo"
provides="zope.interface.Interface"
factory="loops.compound.book.browser.PageLayout"
permission="zope.View" />
<!-- parts -->
<zope:adapter
name="lobo_headline"
for="loops.compound.book.interfaces.IPage
loops.browser.skin.Lobo"
provides="zope.interface.Interface"
factory="loops.compound.book.browser.Headline"
permission="zope.View" />
<zope:adapter
name="lobo_keyquestions"
for="loops.compound.book.interfaces.IPage
loops.browser.skin.Lobo"
provides="zope.interface.Interface"
factory="loops.compound.book.browser.KeyQuestions"
permission="zope.View" />
<zope:adapter
name="lobo_maintext"
for="loops.compound.book.interfaces.IPage
loops.browser.skin.Lobo"
provides="zope.interface.Interface"
factory="loops.compound.book.browser.MainText"
permission="zope.View" />
<zope:adapter
name="lobo_story"
for="loops.compound.book.interfaces.IPage
loops.browser.skin.Lobo"
provides="zope.interface.Interface"
factory="loops.compound.book.browser.Story"
permission="zope.View" />
<zope:adapter
name="lobo_usecase"
for="loops.compound.book.interfaces.IPage
loops.browser.skin.Lobo"
provides="zope.interface.Interface"
factory="loops.compound.book.browser.UseCase"
permission="zope.View" />
<zope:adapter
name="lobo_quote"
for="loops.compound.book.interfaces.IPage
loops.browser.skin.Lobo"
provides="zope.interface.Interface"
factory="loops.compound.book.browser.Quote"
permission="zope.View" />
</configure>

View file

@ -0,0 +1,32 @@
#
# 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
# 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
#
"""
Books, sections, pages...
"""
from zope.interface import Interface, Attribute
from zope import interface, component, schema
from loops.compound.interfaces import ICompound
from loops.util import _
class IPage(ICompound):
pass

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

@ -0,0 +1,21 @@
<html i18n:domain="loops">
<metal:part define-macro="headline">
<div tal:define="cell part/getView">
<metal:headline use-macro="item/macros/headline" />
</div>
</metal:part>
<metal:part define-macro="text">
<tal:cell repeat="cell part/getResources">
<div tal:attributes="class cell/cssClass">
<h3 tal:content="cell/title" />
<span tal:content="structure cell/view/render" />
</div>
</tal:cell>
</metal:part>
</html>

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" />