include setup upon loops site creation in the organize and knowledge packages
git-svn-id: svn://svn.cy55.de/Zope3/src/loops/trunk@1247 fd906abe-77d9-0310-91a1-e0d9ade77398
This commit is contained in:
parent
db5a60a6a3
commit
78310d3eee
9 changed files with 176 additions and 89 deletions
10
helpers.txt
10
helpers.txt
|
@ -30,15 +30,13 @@ Now we can setup a simple loops site with its manager objects, using a
|
||||||
loops setup manager:
|
loops setup manager:
|
||||||
|
|
||||||
>>> from loops import Loops
|
>>> from loops import Loops
|
||||||
>>> site['loops'] = Loops()
|
>>> loopsRoot = site['loops'] = Loops()
|
||||||
>>> loopsRoot = site['loops']
|
|
||||||
|
|
||||||
>>> from loops.setup import SetupManager
|
>>> from loops.setup import SetupManager
|
||||||
>>> setup = SetupManager(loopsRoot)
|
>>> setup = SetupManager(loopsRoot)
|
||||||
>>> setup.setup()
|
>>> concepts, resources, views = setup.setup()
|
||||||
>>> concepts = loopsRoot['concepts']
|
>>> concepts['hasType'].title
|
||||||
>>> resources = loopsRoot['resources']
|
u'has Type'
|
||||||
>>> views = loopsRoot['views']
|
|
||||||
|
|
||||||
We also add some example concepts,
|
We also add some example concepts,
|
||||||
|
|
||||||
|
|
|
@ -18,62 +18,36 @@ 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
|
(with all the type machinery, what in real life is done via standard
|
||||||
ZCML setup):
|
ZCML setup):
|
||||||
|
|
||||||
>>> from loops import Loops
|
|
||||||
>>> from loops.concept import ConceptManager, Concept
|
|
||||||
>>> from loops.resource import ResourceManager
|
|
||||||
>>> from loops.interfaces import IResource, IConcept, ITypeConcept
|
|
||||||
|
|
||||||
>>> loopsRoot = site['loops'] = Loops()
|
|
||||||
|
|
||||||
>>> from cybertools.relation.interfaces import IRelationRegistry
|
>>> from cybertools.relation.interfaces import IRelationRegistry
|
||||||
>>> from cybertools.relation.registry import DummyRelationRegistry
|
>>> from cybertools.relation.registry import DummyRelationRegistry
|
||||||
>>> relations = DummyRelationRegistry()
|
>>> relations = DummyRelationRegistry()
|
||||||
>>> component.provideUtility(relations, IRelationRegistry)
|
>>> component.provideUtility(relations, IRelationRegistry)
|
||||||
|
|
||||||
>>> from cybertools.typology.interfaces import IType
|
>>> from cybertools.typology.interfaces import IType
|
||||||
|
>>> from loops.interfaces import IConcept, ITypeConcept
|
||||||
>>> from loops.type import ConceptType, TypeConcept
|
>>> from loops.type import ConceptType, TypeConcept
|
||||||
>>> component.provideAdapter(ConceptType, (IConcept,), IType)
|
>>> component.provideAdapter(ConceptType, (IConcept,), IType)
|
||||||
>>> component.provideAdapter(TypeConcept, (IConcept,), ITypeConcept)
|
>>> component.provideAdapter(TypeConcept, (IConcept,), ITypeConcept)
|
||||||
|
|
||||||
>>> concepts = loopsRoot['concepts'] = ConceptManager()
|
>>> from loops.interfaces import ILoops
|
||||||
>>> resources = loopsRoot['resources'] = ResourceManager()
|
>>> from loops.setup import ISetupManager
|
||||||
|
>>> from loops.knowledge.setup import SetupManager
|
||||||
|
>>> component.provideAdapter(SetupManager, (ILoops,), ISetupManager,
|
||||||
|
... name='knowledge')
|
||||||
|
|
||||||
>>> hasType = concepts['hasType'] = Concept(u'has type')
|
>>> from loops import Loops
|
||||||
>>> type = concepts['type'] = Concept(u'Type')
|
>>> loopsRoot = site['loops'] = Loops()
|
||||||
>>> type.conceptType = type
|
|
||||||
|
|
||||||
>>> predicate = concepts['predicate'] = Concept(u'Predicate')
|
>>> from loops.setup import SetupManager
|
||||||
>>> predicate.conceptType = type
|
>>> setup = SetupManager(loopsRoot)
|
||||||
>>> hasType.conceptType = predicate
|
>>> concepts, resources, views = setup.setup()
|
||||||
|
|
||||||
We need some predicates to set up the relationships between our concepts:
|
We need some type concepts for controlling the meaning of the concepts objects,
|
||||||
|
these have already been created during setup:
|
||||||
|
|
||||||
>>> standard = concepts['standard'] = Concept(u'subobject')
|
>>> topic = concepts['topic']
|
||||||
>>> depends = concepts['depends'] = Concept(u'depends')
|
>>> person = concepts['person']
|
||||||
>>> knows = concepts['knows'] = Concept(u'knows')
|
>>> task = concepts['task']
|
||||||
>>> requires = concepts['requires'] = Concept(u'requires')
|
|
||||||
>>> provides = concepts['provides'] = Concept(u'provides')
|
|
||||||
|
|
||||||
>>> for p in (standard, depends, knows, requires, provides):
|
|
||||||
... p.conceptType = predicate
|
|
||||||
|
|
||||||
And last not least we need some type concepts for controlling the
|
|
||||||
meaning of the concepts objects:
|
|
||||||
|
|
||||||
>>> from cybertools.knowledge.interfaces import IKnowledgeElement
|
|
||||||
>>> topic = concepts['topic'] = Concept(u'Topic')
|
|
||||||
>>> topic.conceptType = type
|
|
||||||
>>> ITypeConcept(topic).typeInterface = IKnowledgeElement
|
|
||||||
|
|
||||||
>>> from loops.knowledge.interfaces import IPerson
|
|
||||||
>>> person = concepts['person'] = Concept(u'Person')
|
|
||||||
>>> person.conceptType = type
|
|
||||||
>>> ITypeConcept(person).typeInterface = IPerson
|
|
||||||
|
|
||||||
>>> from loops.knowledge.interfaces import ITask
|
|
||||||
>>> task = concepts['task'] = Concept(u'Task')
|
|
||||||
>>> task.conceptType = type
|
|
||||||
>>> ITypeConcept(task).typeInterface = ITask
|
|
||||||
|
|
||||||
|
|
||||||
Manage knowledge and knowledge requirements
|
Manage knowledge and knowledge requirements
|
||||||
|
@ -82,6 +56,9 @@ Manage knowledge and knowledge requirements
|
||||||
The classes used in this package are just adapters to IConcept.
|
The classes used in this package are just adapters to IConcept.
|
||||||
|
|
||||||
>>> from loops.knowledge.knowledge import Person, Topic, Task
|
>>> from loops.knowledge.knowledge import Person, Topic, Task
|
||||||
|
>>> from loops.knowledge.interfaces import IPerson
|
||||||
|
>>> from cybertools.knowledge.interfaces import IKnowledgeElement
|
||||||
|
>>> from loops.knowledge.interfaces import ITask
|
||||||
>>> component.provideAdapter(Person, (IConcept,), IPerson)
|
>>> component.provideAdapter(Person, (IConcept,), IPerson)
|
||||||
>>> component.provideAdapter(Topic, (IConcept,), IKnowledgeElement)
|
>>> component.provideAdapter(Topic, (IConcept,), IKnowledgeElement)
|
||||||
>>> component.provideAdapter(Task, (IConcept,), ITask)
|
>>> component.provideAdapter(Task, (IConcept,), ITask)
|
||||||
|
@ -91,6 +68,7 @@ interdependencies. Note that in order to discern the concepts created
|
||||||
from their typeInterface adapters we here append a 'C' to the name of
|
from their typeInterface adapters we here append a 'C' to the name of
|
||||||
the variables:
|
the variables:
|
||||||
|
|
||||||
|
>>> from loops.concept import Concept
|
||||||
>>> progLangC = concepts['progLang'] = Concept(u'Programming Language')
|
>>> progLangC = concepts['progLang'] = Concept(u'Programming Language')
|
||||||
>>> ooProgC = concepts['ooProg'] = Concept(u'Object-oriented Programming')
|
>>> ooProgC = concepts['ooProg'] = Concept(u'Object-oriented Programming')
|
||||||
>>> pythonC = concepts['python'] = Concept(u'Python')
|
>>> pythonC = concepts['python'] = Concept(u'Python')
|
||||||
|
@ -142,6 +120,7 @@ a position with the requirement profile:
|
||||||
Luckily there are a few elearning content objects out there that
|
Luckily there are a few elearning content objects out there that
|
||||||
provide some of the knowledge needed:
|
provide some of the knowledge needed:
|
||||||
|
|
||||||
|
>>> from loops.interfaces import IResource
|
||||||
>>> from cybertools.knowledge.interfaces import IKnowledgeProvider
|
>>> from cybertools.knowledge.interfaces import IKnowledgeProvider
|
||||||
>>> from loops.knowledge.knowledge import ConceptKnowledgeProvider
|
>>> from loops.knowledge.knowledge import ConceptKnowledgeProvider
|
||||||
>>> component.provideAdapter(ConceptKnowledgeProvider, (IConcept,))
|
>>> component.provideAdapter(ConceptKnowledgeProvider, (IConcept,))
|
||||||
|
|
|
@ -75,5 +75,9 @@
|
||||||
permission="zope.View"
|
permission="zope.View"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
<!-- other adapters -->
|
||||||
|
|
||||||
|
<zope:adapter factory="loops.knowledge.setup.SetupManager"
|
||||||
|
name="knowledge" />
|
||||||
|
|
||||||
</configure>
|
</configure>
|
||||||
|
|
61
knowledge/setup.py
Normal file
61
knowledge/setup.py
Normal file
|
@ -0,0 +1,61 @@
|
||||||
|
#
|
||||||
|
# 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
|
||||||
|
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 = IKnowledgeElement
|
||||||
|
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)
|
||||||
|
|
||||||
|
|
|
@ -18,38 +18,35 @@ 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
|
(with all the type machinery, what in real life is done via standard
|
||||||
ZCML setup):
|
ZCML setup):
|
||||||
|
|
||||||
>>> from loops import Loops
|
|
||||||
>>> from loops.concept import ConceptManager, Concept
|
|
||||||
>>> from loops.interfaces import IConcept, ITypeConcept
|
|
||||||
|
|
||||||
>>> loopsRoot = site['loops'] = Loops()
|
|
||||||
|
|
||||||
>>> from cybertools.relation.interfaces import IRelationRegistry
|
>>> from cybertools.relation.interfaces import IRelationRegistry
|
||||||
>>> from cybertools.relation.registry import DummyRelationRegistry
|
>>> from cybertools.relation.registry import DummyRelationRegistry
|
||||||
>>> relations = DummyRelationRegistry()
|
>>> relations = DummyRelationRegistry()
|
||||||
>>> component.provideUtility(relations, IRelationRegistry)
|
>>> component.provideUtility(relations, IRelationRegistry)
|
||||||
|
|
||||||
>>> from cybertools.typology.interfaces import IType
|
>>> from cybertools.typology.interfaces import IType
|
||||||
|
>>> from loops.interfaces import IConcept, ITypeConcept
|
||||||
>>> from loops.type import ConceptType, TypeConcept
|
>>> from loops.type import ConceptType, TypeConcept
|
||||||
>>> component.provideAdapter(ConceptType, (IConcept,), IType)
|
>>> component.provideAdapter(ConceptType, (IConcept,), IType)
|
||||||
>>> component.provideAdapter(TypeConcept, (IConcept,), ITypeConcept)
|
>>> component.provideAdapter(TypeConcept, (IConcept,), ITypeConcept)
|
||||||
|
|
||||||
>>> loopsRoot['concepts'] = ConceptManager()
|
>>> from loops.interfaces import ILoops
|
||||||
>>> concepts = loopsRoot['concepts']
|
>>> from loops.setup import ISetupManager
|
||||||
|
>>> from loops.organize.setup import SetupManager
|
||||||
|
>>> component.provideAdapter(SetupManager, (ILoops,), ISetupManager,
|
||||||
|
... name='organize')
|
||||||
|
|
||||||
|
>>> from loops import Loops
|
||||||
|
>>> loopsRoot = site['loops'] = Loops()
|
||||||
|
|
||||||
|
>>> from loops.setup import SetupManager
|
||||||
|
>>> setup = SetupManager(loopsRoot)
|
||||||
|
>>> concepts, resources, views = setup.setup()
|
||||||
|
|
||||||
>>> concepts['hasType'] = Concept(u'has type')
|
|
||||||
>>> concepts['type'] = Concept(u'Type')
|
|
||||||
>>> type = concepts['type']
|
>>> type = concepts['type']
|
||||||
>>> type.conceptType = type
|
|
||||||
|
|
||||||
>>> from loops.organize.interfaces import IPerson
|
|
||||||
>>> concepts['person'] = Concept(u'Person')
|
|
||||||
>>> person = concepts['person']
|
>>> person = concepts['person']
|
||||||
>>> person.conceptType = type
|
|
||||||
>>> ITypeConcept(person).typeInterface = IPerson
|
|
||||||
|
|
||||||
>>> johnC = Concept(u'John')
|
>>> from loops.concept import Concept
|
||||||
>>> concepts['john'] = johnC
|
>>> johnC = concepts['john'] = Concept(u'John')
|
||||||
>>> johnC.conceptType = person
|
>>> johnC.conceptType = person
|
||||||
|
|
||||||
|
|
||||||
|
@ -58,6 +55,7 @@ Organizations: Persons (and Users), Institutions, Addresses...
|
||||||
|
|
||||||
The classes used in this package are just adapters to IConcept.
|
The classes used in this package are just adapters to IConcept.
|
||||||
|
|
||||||
|
>>> from loops.organize.interfaces import IPerson
|
||||||
>>> from loops.organize.party import Person
|
>>> from loops.organize.party import Person
|
||||||
>>> component.provideAdapter(Person, (IConcept,), IPerson)
|
>>> component.provideAdapter(Person, (IConcept,), IPerson)
|
||||||
|
|
||||||
|
@ -102,7 +100,6 @@ For testing, we first have to provide the needed utilities and settings
|
||||||
>>> component.provideUtility(principalAnnotations, IPrincipalAnnotationUtility)
|
>>> component.provideUtility(principalAnnotations, IPrincipalAnnotationUtility)
|
||||||
|
|
||||||
>>> principal = auth.definePrincipal('users.john', u'John', login='john')
|
>>> principal = auth.definePrincipal('users.john', u'John', login='john')
|
||||||
|
|
||||||
>>> john.userId = 'users.john'
|
>>> john.userId = 'users.john'
|
||||||
|
|
||||||
>>> annotations = principalAnnotations.getAnnotationsById('users.john')
|
>>> annotations = principalAnnotations.getAnnotationsById('users.john')
|
||||||
|
@ -154,8 +151,7 @@ concept assigned we should get an error:
|
||||||
|
|
||||||
>>> john.userId = 'users.john'
|
>>> john.userId = 'users.john'
|
||||||
|
|
||||||
>>> marthaC = Concept(u'Martha')
|
>>> marthaC = concepts['martha'] = Concept(u'Martha')
|
||||||
>>> concepts['martha'] = marthaC
|
|
||||||
>>> marthaC.conceptType = person
|
>>> marthaC.conceptType = person
|
||||||
>>> martha = IPerson(marthaC)
|
>>> martha = IPerson(marthaC)
|
||||||
|
|
||||||
|
@ -192,14 +188,12 @@ with a principal folder:
|
||||||
In addition, we have to create at least one node in the view space
|
In addition, we have to create at least one node in the view space
|
||||||
and register an IMemberRegistrationManager adapter for the loops root object:
|
and register an IMemberRegistrationManager adapter for the loops root object:
|
||||||
|
|
||||||
>>> from loops.view import ViewManager, Node
|
>>> from loops.view import Node
|
||||||
>>> views = loopsRoot['views'] = ViewManager()
|
|
||||||
>>> menu = views['menu'] = Node('Home')
|
>>> menu = views['menu'] = Node('Home')
|
||||||
>>> menu.nodeType = 'menu'
|
>>> menu.nodeType = 'menu'
|
||||||
|
|
||||||
>>> from loops.organize.member import MemberRegistrationManager
|
>>> from loops.organize.member import MemberRegistrationManager
|
||||||
>>> from loops.organize.interfaces import IMemberRegistrationManager
|
>>> from loops.organize.interfaces import IMemberRegistrationManager
|
||||||
>>> from loops.interfaces import ILoops
|
|
||||||
>>> component.provideAdapter(MemberRegistrationManager)
|
>>> component.provideAdapter(MemberRegistrationManager)
|
||||||
|
|
||||||
Now we can enter the registration info for a new member (after having made
|
Now we can enter the registration info for a new member (after having made
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
"""
|
"""
|
||||||
$Id$
|
$Id$
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
|
@ -90,4 +90,9 @@
|
||||||
permission="zope.Public"
|
permission="zope.Public"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
<!-- other adapters -->
|
||||||
|
|
||||||
|
<zope:adapter factory="loops.organize.setup.SetupManager"
|
||||||
|
name="organize" />
|
||||||
|
|
||||||
</configure>
|
</configure>
|
||||||
|
|
44
organize/setup.py
Normal file
44
organize/setup.py
Normal file
|
@ -0,0 +1,44 @@
|
||||||
|
#
|
||||||
|
# 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 loops.concept import Concept
|
||||||
|
from loops.interfaces import ITypeConcept
|
||||||
|
from loops.organize.interfaces import IPerson
|
||||||
|
from loops.setup import SetupManager as BaseSetupManager
|
||||||
|
|
||||||
|
|
||||||
|
class SetupManager(BaseSetupManager):
|
||||||
|
|
||||||
|
def setup(self):
|
||||||
|
concepts = self.context.getConceptManager()
|
||||||
|
type = concepts.getTypeConcept()
|
||||||
|
person = self.addObject(concepts, Concept, 'person', title=u'Person',
|
||||||
|
conceptType=type)
|
||||||
|
personTypeAdapter = ITypeConcept(person)
|
||||||
|
if not personTypeAdapter.typeInterface: # only set if not set yet
|
||||||
|
personTypeAdapter.typeInterface = IPerson
|
||||||
|
|
23
setup.py
23
setup.py
|
@ -22,12 +22,11 @@ Automatic setup of a loops site.
|
||||||
$Id$
|
$Id$
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import transaction
|
|
||||||
from zope.app.event.objectevent import ObjectCreatedEvent, ObjectModifiedEvent
|
from zope.app.event.objectevent import ObjectCreatedEvent, ObjectModifiedEvent
|
||||||
from zope.event import notify
|
from zope.event import notify
|
||||||
|
from zope import component
|
||||||
from zope.component import adapts
|
from zope.component import adapts
|
||||||
from zope.interface import implements, Interface
|
from zope.interface import implements, Interface
|
||||||
from zope.cachedescriptors.property import Lazy
|
|
||||||
|
|
||||||
from loops.interfaces import ILoops
|
from loops.interfaces import ILoops
|
||||||
from loops.concept import ConceptManager, Concept
|
from loops.concept import ConceptManager, Concept
|
||||||
|
@ -56,6 +55,11 @@ class SetupManager(object):
|
||||||
def setup(self):
|
def setup(self):
|
||||||
concepts, resources, views = self.setupManagers()
|
concepts, resources, views = self.setupManagers()
|
||||||
self.setupCoreConcepts(concepts)
|
self.setupCoreConcepts(concepts)
|
||||||
|
appSetups = dict(component.getAdapters((self.context,), ISetupManager))
|
||||||
|
for smName in appSetups:
|
||||||
|
if smName: # skip core (unnamed), i.e. this, adapter
|
||||||
|
appSetups[smName].setup()
|
||||||
|
return concepts, resources, views # just for convenience when testing
|
||||||
|
|
||||||
def setupManagers(self):
|
def setupManagers(self):
|
||||||
loopsRoot = self.context
|
loopsRoot = self.context
|
||||||
|
@ -65,22 +69,21 @@ class SetupManager(object):
|
||||||
return concepts, resources, views
|
return concepts, resources, views
|
||||||
|
|
||||||
def setupCoreConcepts(self, conceptManager):
|
def setupCoreConcepts(self, conceptManager):
|
||||||
typeConcept = self.addObject(conceptManager, Concept, 'type', u'Type')
|
typeConcept = self.addObject(conceptManager, Concept, 'type', title=u'Type')
|
||||||
hasType = self.addObject(conceptManager, Concept, 'hasType', u'has type')
|
hasType = self.addObject(conceptManager, Concept, 'hasType', title=u'has Type')
|
||||||
predicate = self.addObject(conceptManager, Concept, 'predicate', u'Predicate')
|
predicate = self.addObject(conceptManager, Concept, 'predicate', title=u'Predicate')
|
||||||
standard = self.addObject(conceptManager, Concept, 'standard', u'subobject')
|
standard = self.addObject(conceptManager, Concept, 'standard', title=u'subobject')
|
||||||
typeConcept.conceptType = typeConcept
|
typeConcept.conceptType = typeConcept
|
||||||
predicate.conceptType = typeConcept
|
predicate.conceptType = typeConcept
|
||||||
hasType.conceptType = predicate
|
hasType.conceptType = predicate
|
||||||
standard.conceptType = predicate
|
standard.conceptType = predicate
|
||||||
|
|
||||||
def addObject(self, container, class_, name, title=None):
|
def addObject(self, container, class_, name, **kw):
|
||||||
if name in container:
|
if name in container:
|
||||||
return container[name]
|
return container[name]
|
||||||
if title:
|
|
||||||
obj = container[name] = class_(title)
|
|
||||||
else:
|
|
||||||
obj = container[name] = class_()
|
obj = container[name] = class_()
|
||||||
|
for attr in kw:
|
||||||
|
setattr(obj, attr, kw[attr])
|
||||||
notify(ObjectCreatedEvent(obj))
|
notify(ObjectCreatedEvent(obj))
|
||||||
notify(ObjectModifiedEvent(obj))
|
notify(ObjectModifiedEvent(obj))
|
||||||
return obj
|
return obj
|
||||||
|
|
Loading…
Add table
Reference in a new issue