diff --git a/xmlrpc/README.txt b/xmlrpc/README.txt index ace0bfd..126b141 100755 --- a/xmlrpc/README.txt +++ b/xmlrpc/README.txt @@ -41,18 +41,15 @@ Let's look what setup has provided us with: Now let's add a few more concepts: - >>> topic = concepts[u'topic'] = Concept() - >>> topic.title = u'Topic' + >>> topic = concepts[u'topic'] = Concept(u'Topic') >>> intIds.register(topic) 7 - >>> zope = concepts[u'zope'] = Concept() + >>> zope = concepts[u'zope'] = Concept(u'Zope') >>> zope.conceptType = topic - >>> zope.title = u'Zope' >>> intIds.register(zope) 8 - >>> zope3 = concepts[u'zope3'] = Concept() + >>> zope3 = concepts[u'zope3'] = Concept(u'Zope 3') >>> zope3.conceptType = topic - >>> zope3.title = u'Zope 3' >>> intIds.register(zope3) 9 @@ -149,9 +146,14 @@ Updating the concept map >>> zope3Id = xrf.getObjectByName('zope3')['id'] >>> xrf.assignChild(zopeId, zope3Id, defaultPred['id']) 'OK' + >>> xrf.deassignChild(zopeId, zope3Id, defaultPred['id']) 'OK' + >>> topicId = xrf.getObjectByName('topic')['id'] + >>> xrf.createConcept(topicId, u'zope2', u'Zope 2') + '12' + Fin de partie ============= diff --git a/xmlrpc/common.py b/xmlrpc/common.py index 08e2e0c..2619122 100644 --- a/xmlrpc/common.py +++ b/xmlrpc/common.py @@ -29,6 +29,7 @@ from zope.app.traversing.api import getName from zope.security.proxy import removeSecurityProxy from zope.cachedescriptors.property import Lazy +from loops.concept import Concept from loops.util import getUidForObject, getObjectForUid class LoopsMethods(MethodPublisher): @@ -65,6 +66,7 @@ class LoopsMethods(MethodPublisher): def getConceptTypes(self): tc = self.concepts.getTypeConcept() types = tc.getChildren((self.concepts.getTypePredicate(),)) + #types = [t for t in types if ITypeConcept(t).typeInterface ... ] return [objectAsDict(t) for t in types] def getPredicates(self): @@ -107,6 +109,13 @@ class LoopsMethods(MethodPublisher): obj.deassignChild(child, [pred]) return 'OK' + def createConcept(self, typeId, name, title): + type = getObjectForUid(typeId) + c = self.concepts[name] = Concept(title) + c.conceptType = type + # notify + return getUidForObject(c) + def objectAsDict(obj): mapping = {'id': getUidForObject(obj), 'name': getName(obj), 'title': obj.title, diff --git a/xmlrpc/configure.zcml b/xmlrpc/configure.zcml index 3fc2e6f..c7cfebc 100644 --- a/xmlrpc/configure.zcml +++ b/xmlrpc/configure.zcml @@ -26,7 +26,7 @@ getDefaultPredicate getTypePredicate getTypeConcept getConceptTypes getPredicates getChildren getParents - assignChild deassignChild" + assignChild deassignChild createConcept" permission="loops.xmlrpc.ManageConcepts" />