added XML-RPC method createConcept()
git-svn-id: svn://svn.cy55.de/Zope3/src/loops/trunk@1576 fd906abe-77d9-0310-91a1-e0d9ade77398
This commit is contained in:
parent
5bf5123847
commit
bd1f1a69ce
3 changed files with 18 additions and 7 deletions
|
@ -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
|
||||
=============
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
getDefaultPredicate getTypePredicate getTypeConcept
|
||||
getConceptTypes getPredicates
|
||||
getChildren getParents
|
||||
assignChild deassignChild"
|
||||
assignChild deassignChild createConcept"
|
||||
permission="loops.xmlrpc.ManageConcepts"
|
||||
/>
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue