replace setup manager (for package loops.knowledge) by import file

This commit is contained in:
Helmut Merz 2012-05-18 10:05:17 +02:00
parent a2590958d0
commit ef504afc0b
5 changed files with 51 additions and 77 deletions

View file

@ -2,33 +2,34 @@
loops - Linked Objects for Organization and Processing Services
===============================================================
($Id$)
Note: This package depends on cybertools.knowledge and cybertools.organize.
Note: This package depends on cybertools.knowledge and loops.organize.
Let's do some basic set up
>>> from zope import component, interface
>>> from zope.app.testing.setup import placefulSetUp, placefulTearDown
>>> site = placefulSetUp(True)
>>> from zope import component, interface
and setup a simple loops site with a concept manager and some concepts
(with all the type machinery, what in real life is done via standard
ZCML setup):
>>> from loops.interfaces import ILoops, IConcept
>>> from loops.setup import ISetupManager
>>> from loops.knowledge.setup import SetupManager
>>> component.provideAdapter(SetupManager, (ILoops,), ISetupManager,
... name='knowledge')
>>> from loops.tests.setup import TestSite
>>> t = TestSite(site)
>>> concepts, resources, views = t.setup()
>>> loopsRoot = site['loops']
We then import a loops .dmp file containing all necessary types and
predicates.
>>> import os
>>> from loops.setup import importData
>>> importPath = os.path.join(os.path.dirname(__file__), 'data')
>>> importData(loopsRoot, importPath, 'loops_knowledge_de.dmp')
We need some type concepts for controlling the meaning of the concepts objects,
these have already been created during setup:
these have already been created during setup and .dmp import:
>>> topic = concepts['topic']
>>> person = concepts['person']
@ -40,6 +41,7 @@ Manage knowledge and knowledge requirements
The classes used in this package are just adapters to IConcept.
>>> from loops.interfaces import IConcept
>>> from loops.knowledge.knowledge import Person, Topic, Task
>>> from loops.knowledge.interfaces import IPerson
>>> from cybertools.knowledge.interfaces import IKnowledgeElement
@ -166,6 +168,10 @@ For testing, we first have to provide the needed utilities and settings
>>> view = MyKnowledge(task01C, request)
>>> prov = view.myKnowledgeProvidersForTask()
Competence and Certification Management
=======================================
Glossaries
==========

View file

@ -88,9 +88,6 @@
<zope:adapter factory="loops.knowledge.schema.PersonSchemaFactory" />
<zope:adapter factory="loops.knowledge.setup.SetupManager"
name="knowledge" />
<!-- sub-packages -->
<include package=".glossary" />

View file

@ -0,0 +1,32 @@
type(u'person', u'Person', viewName=u'',
typeInterface=u'loops.knowledge.interfaces.IPerson',
options=u'action.portlet:editPerson')
type(u'task', u'Aufgabe', viewName=u'',
typeInterface=u'loops.knowledge.interfaces.ITask',
options=u'action.portlet:createTopic,editTopic')
type(u'topic', u'Thema', viewName=u'',
typeInterface=u'loops.knowledge.interfaces.ITopic',
options=u'action.portlet:createTopic,editTopic')
concept(u'general', u'Allgemein', u'domain')
concept(u'system', u'System', u'domain')
# predicates
concept(u'depends', u'depends', u'predicate')
concept(u'knows', u'knows', u'predicate')
concept(u'provides', u'provides', u'predicate')
concept(u'requires', u'requires', u'predicate')
concept(u'issubtype', u'is Subtype', u'predicate', options=u'hide_children',
predicateInterface='loops.interfaces.IIsSubtype')
# structure
child(u'depends', u'general', u'standard')
child(u'knows', u'general', u'standard')
child(u'person', u'general', u'standard')
child(u'provides', u'general', u'standard')
child(u'requires', u'general', u'standard')
child(u'task', u'general', u'standard')
child(u'topic', u'general', u'standard')
child(u'issubtype', u'system', u'standard')

View file

@ -1,61 +0,0 @@
#
# 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
#
"""
Automatic setup of a loops site for the organize package.
$Id$
"""
from zope.component import adapts
from zope.interface import implements, Interface
from cybertools.knowledge.interfaces import IKnowledgeElement
from loops.concept import Concept
from loops.interfaces import ITypeConcept
from loops.knowledge.interfaces import IPerson, ITask, ITopic
from loops.setup import SetupManager as BaseSetupManager
class SetupManager(BaseSetupManager):
def setup(self):
concepts = self.context.getConceptManager()
type = concepts.getTypeConcept()
predicate = concepts['predicate']
# type concepts:
person = self.addObject(concepts, Concept, 'person', title=u'Person',
conceptType=type)
ITypeConcept(person).typeInterface = IPerson # this may override other packages!
topic = self.addObject(concepts, Concept, 'topic', title=u'Topic',
conceptType=type)
ITypeConcept(topic).typeInterface = ITopic
task = self.addObject(concepts, Concept, 'task', title=u'Task',
conceptType=type)
ITypeConcept(task).typeInterface = ITask
# predicates:
depends = self.addObject(concepts, Concept, 'depends', title=u'depends',
conceptType=predicate)
knows = self.addObject(concepts, Concept, 'knows', title=u'knows',
conceptType=predicate)
requires = self.addObject(concepts, Concept, 'requires', title=u'requires',
conceptType=predicate)
provides = self.addObject(concepts, Concept, 'provides', title=u'provides',
conceptType=predicate)

View file

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