diff --git a/concept.py b/concept.py index ac6c7bb..9cd9daa 100644 --- a/concept.py +++ b/concept.py @@ -215,7 +215,7 @@ class ConceptManager(BTreeContainer): def getDefaultPredicate(self): if self.defaultPredicate is None: - self.defaultPredicate = self['standard'] + self.defaultPredicate = self.get('standard') return self.defaultPredicate def getPredicateType(self): diff --git a/helpers.txt b/helpers.txt index 05fce3a..892da3b 100755 --- a/helpers.txt +++ b/helpers.txt @@ -236,9 +236,10 @@ get a type manager from all loops objects, always with the same context: >>> types = typeManager.types >>> sorted(t.token for t in types) - ['.loops/concepts/file', '.loops/concepts/image', '.loops/concepts/predicate', - '.loops/concepts/textdocument', '.loops/concepts/topic', - '.loops/concepts/type'] + ['.loops/concepts/domain', '.loops/concepts/file', + '.loops/concepts/predicate', '.loops/concepts/query', + '.loops/concepts/textdocument', '.loops/concepts/topic', + '.loops/concepts/type'] >>> typeManager.getType('.loops/concepts/topic') == cc1_type True @@ -248,11 +249,11 @@ condition: >>> types = typeManager.listTypes(include=('concept',)) >>> sorted(t.token for t in types) - ['.loops/concepts/predicate', '.loops/concepts/topic', '.loops/concepts/type'] + ['.loops/concepts/domain', '.loops/concepts/predicate', + '.loops/concepts/query', '.loops/concepts/topic', '.loops/concepts/type'] >>> types = typeManager.listTypes(exclude=('concept',)) >>> sorted(t.token for t in types) - ['.loops/concepts/file', '.loops/concepts/image', - '.loops/concepts/textdocument'] + ['.loops/concepts/file', '.loops/concepts/textdocument'] Type-based interfaces and adapters @@ -313,14 +314,12 @@ Concepts as queries ------------------- We first have to set up the query type, i.e. a type concept associated -with the IQueryConcept interface: +with the IQueryConcept interface. The query type concept itself has already +been provided by the setup, but we have to register a corresponding adapter. - >>> from loops.query import IQueryConcept, QueryConcept - >>> component.provideAdapter(QueryConcept, (IConcept,), IQueryConcept) - - >>> query = concepts['query'] = Concept(u'Query') - >>> query.conceptType = typeObject - >>> ITypeConcept(query).typeInterface = IQueryConcept + >>> from loops.query import QueryConcept + >>> component.provideAdapter(QueryConcept) + >>> query = concepts['query'] Next we need a concept of this type: diff --git a/rest/README.txt b/rest/README.txt index d531460..ec7b5ca 100755 --- a/rest/README.txt +++ b/rest/README.txt @@ -34,8 +34,9 @@ ZCML setup): Let's look what setup has provided us with: - >>> list(concepts) - [u'file', u'hasType', u'image', u'predicate', u'standard', u'textdocument', u'type'] + >>> sorted(concepts) + [u'domain', u'file', u'hasType', u'note', u'predicate', u'query', + u'standard', u'textdocument', u'type'] loops Traversal @@ -54,14 +55,14 @@ returns a REST view of the object. >>> component.provideAdapter(ConceptView) Navigation typically starts at a start object, which by default ist the -top-level type concept: +domain type concept (or the top-level type concept, if there is no domain type): >>> request = TestRequest() >>> obj = LoopsTraverser(loopsRoot, request).publishTraverse(request, 'startObject') >>> obj >>> obj.context.title - u'Type' + u'Domain' The traversal adapter returns a view that when called renders the representation of its context object: diff --git a/search/README.txt b/search/README.txt index 442f15f..51fa0e5 100755 --- a/search/README.txt +++ b/search/README.txt @@ -37,9 +37,9 @@ ZCML setup): >>> typeConcept = concepts['type'] >>> from loops.concept import Concept - >>> query = concepts['query'] = Concept(u'Query') >>> topic = concepts['topic'] = Concept(u'Topic') - >>> for c in (query, topic): c.conceptType = typeConcept + >>> for c in (topic,): c.conceptType = typeConcept + >>> query = concepts['query'] In addition we create a concept that holds the search page and a node (page) that links to this concept: @@ -84,7 +84,7 @@ zcml in real life: >>> t = searchView.conceptTypesForSearch() >>> len(t) - 3 + 4 >>> t.getTermByToken('loops:concept:*').title 'Any Concept' diff --git a/setup.py b/setup.py index fb1ff08..2ad80e1 100644 --- a/setup.py +++ b/setup.py @@ -28,8 +28,10 @@ from zope import component from zope.component import adapts from zope.interface import implements, Interface -from loops.interfaces import ILoops, ITypeConcept, IFile, IImage, ITextDocument +from loops.interfaces import ILoops, ITypeConcept +from loops.interfaces import IFile, IImage, ITextDocument, INote from loops.concept import ConceptManager, Concept +from loops.query import IQueryConcept from loops.resource import ResourceManager from loops.view import ViewManager, Node @@ -73,16 +75,21 @@ class SetupManager(object): hasType = self.addObject(conceptManager, Concept, 'hasType', title=u'has Type') predicate = self.addObject(conceptManager, Concept, 'predicate', title=u'Predicate') standard = self.addObject(conceptManager, Concept, 'standard', title=u'subobject') + domain = self.addObject(conceptManager, Concept, 'domain', title=u'Domain') + query = self.addObject(conceptManager, Concept, 'query', title=u'Query') file = self.addObject(conceptManager, Concept, 'file', title=u'File') - image = self.addObject(conceptManager, Concept, 'image', title=u'Image') + #image = self.addObject(conceptManager, Concept, 'image', title=u'Image') textdocument = self.addObject(conceptManager, Concept, - 'textdocument', title=u'Text Document') - for c in (typeConcept, file, image, textdocument, predicate): + 'textdocument', title=u'Text') + note = self.addObject(conceptManager, Concept, 'note', title=u'Note') + for c in (typeConcept, domain, query, file, textdocument, predicate): c.conceptType = typeConcept ITypeConcept(typeConcept).typeInterface = ITypeConcept + ITypeConcept(query).typeInterface = IQueryConcept ITypeConcept(file).typeInterface = IFile - ITypeConcept(image).typeInterface = IImage + #ITypeConcept(image).typeInterface = IImage ITypeConcept(textdocument).typeInterface = ITextDocument + ITypeConcept(note).typeInterface = INote hasType.conceptType = predicate standard.conceptType = predicate diff --git a/xmlrpc/README.txt b/xmlrpc/README.txt index d93cb50..5415b3f 100755 --- a/xmlrpc/README.txt +++ b/xmlrpc/README.txt @@ -36,25 +36,26 @@ ZCML setup): Let's look what setup has provided us with: - >>> list(concepts) - [u'file', u'hasType', u'image', u'predicate', u'standard', u'textdocument', u'type'] + >>> sorted(concepts) + [u'domain', u'file', u'hasType', u'note', u'predicate', u'query', + u'standard', u'textdocument', u'type'] Now let's add a few more concepts: >>> topic = concepts[u'topic'] = Concept(u'Topic') >>> intIds.register(topic) - 7 + 8 >>> zope = concepts[u'zope'] = Concept(u'Zope') >>> zope.conceptType = topic >>> intIds.register(zope) - 8 + 9 >>> zope3 = concepts[u'zope3'] = Concept(u'Zope 3') >>> zope3.conceptType = topic >>> intIds.register(zope3) - 9 + 10 Navigation typically starts at a start object, which by default ist the -top-level type concept: +domain concept (if present, otherwise the top-level type concept): >>> from loops.xmlrpc.common import LoopsMethods >>> xrf = LoopsMethods(loopsRoot, TestRequest()) @@ -62,27 +63,16 @@ top-level type concept: >>> sorted(startObj.keys()) ['children', 'id', 'name', 'parents', 'title', 'type'] >>> startObj['id'], startObj['name'], startObj['title'], startObj['type'] - ('0', u'type', u'Type', '0') - -If we provide a concept named "domain" this will be used as starting point: - - >>> from loops.concept import Concept - >>> domain = concepts[u'domain'] = Concept(u'Domain') - >>> domain.conceptType = concepts.getTypeConcept() - >>> startObj = xrf.getStartObject() - >>> sorted(startObj.keys()) - ['children', 'id', 'name', 'parents', 'title', 'type'] - >>> startObj['id'], startObj['name'], startObj['title'], startObj['type'] - ('10', u'domain', u'Domain', '0') + ('1', u'domain', u'Domain', '0') There are a few standard objects we can retrieve directly: >>> defaultPred = xrf.getDefaultPredicate() >>> defaultPred['id'], defaultPred['name'] - ('6', u'standard') + ('7', u'standard') >>> typePred = xrf.getTypePredicate() >>> typePred['id'], typePred['name'] - ('5', u'hasType') + ('6', u'hasType') >>> typeConcept = xrf.getTypeConcept() >>> typeConcept['id'], typeConcept['name'] ('0', u'type') @@ -90,7 +80,7 @@ There are a few standard objects we can retrieve directly: In addition we can get a list of all types and all predicates available: >>> sorted(t['name'] for t in xrf.getConceptTypes()) - [u'domain', u'file', u'image', u'predicate', u'textdocument', u'type'] + [u'domain', u'file', u'predicate', u'query', u'textdocument', u'type'] >>> sorted(t['name'] for t in xrf.getPredicates()) [u'hasType', u'standard'] @@ -98,10 +88,10 @@ We can also retrieve a certain object by its id or its name: >>> obj2 = xrf.getObjectById('2') >>> obj2['id'], obj2['name'] - ('2', u'image') + ('2', u'query') >>> textdoc = xrf.getObjectByName(u'textdocument') >>> textdoc['id'], textdoc['name'] - ('3', u'textdocument') + ('4', u'textdocument') All methods that retrieve one object also returns its children and parents: @@ -111,7 +101,7 @@ All methods that retrieve one object also returns its children and parents: >>> ch[0]['name'] u'hasType' >>> sorted(c['name'] for c in ch[0]['objects']) - [u'domain', u'file', u'image', u'predicate', u'textdocument', u'type'] + [u'domain', u'file', u'predicate', u'query', u'textdocument', u'type'] >>> pa = defaultPred['parents'] >>> len(pa) @@ -129,7 +119,7 @@ We can also retrieve children and parents explicitely: >>> ch[0]['name'] u'hasType' >>> sorted(c['name'] for c in ch[0]['objects']) - [u'domain', u'file', u'image', u'predicate', u'textdocument', u'type'] + [u'domain', u'file', u'predicate', u'query', u'textdocument', u'type'] >>> pa = xrf.getParents('6') >>> len(pa) @@ -152,7 +142,7 @@ Updating the concept map >>> topicId = xrf.getObjectByName('topic')['id'] >>> xrf.createConcept(topicId, u'zope2', u'Zope 2') - {'title': u'Zope 2', 'type': '7', 'id': '12', 'name': u'zope2'} + {'title': u'Zope 2', 'type': '8', 'id': '12', 'name': u'zope2'} Fin de partie