autogenerate name on XML-RPC view (for concept map editor)
git-svn-id: svn://svn.cy55.de/Zope3/src/loops/trunk@1793 fd906abe-77d9-0310-91a1-e0d9ade77398
This commit is contained in:
parent
e0c9b96a10
commit
331e1894b1
4 changed files with 19 additions and 6 deletions
|
@ -45,7 +45,7 @@ from loops.browser.common import EditForm, BaseView, Action
|
|||
from loops.browser.concept import ConceptRelationView, ConceptConfigureView
|
||||
from loops.browser.node import NodeView, node_macros
|
||||
from loops.browser.util import html_quote
|
||||
from loops.common import adapted
|
||||
from loops.common import adapted, NameChooser
|
||||
from loops.interfaces import IBaseResource, IDocument, IMediaAsset, ITextDocument
|
||||
from loops.interfaces import ITypeConcept
|
||||
from loops.versioning.browser import version_macros
|
||||
|
@ -165,7 +165,7 @@ class ResourceView(BaseView):
|
|||
if useAttachment:
|
||||
filename = adapted(self.context).localFilename or getName(self.context)
|
||||
#filename = urllib.quote(filename)
|
||||
filename = INameChooser(getParent(self.context)).normalizeName(filename)
|
||||
filename = NameChooser(getParent(self.context)).normalizeName(filename)
|
||||
response.setHeader('Content-Disposition',
|
||||
'attachment; filename=%s' % filename)
|
||||
return data
|
||||
|
|
|
@ -460,13 +460,14 @@
|
|||
name="loops.PredicateSource" />
|
||||
|
||||
|
||||
<include package=".browser" />
|
||||
<include package=".classifier" />
|
||||
<include package=".integrator" />
|
||||
<include package=".knowledge" />
|
||||
<include package=".organize" />
|
||||
<include package=".integrator" />
|
||||
<include package=".process" />
|
||||
<include package=".versioning" />
|
||||
<include package=".search" />
|
||||
<include package=".browser" />
|
||||
<include package=".versioning" />
|
||||
<include package=".xmlrpc" />
|
||||
<include package=".rest" />
|
||||
|
||||
|
|
|
@ -28,6 +28,8 @@ ZCML setup):
|
|||
>>> component.provideAdapter(LoopsType)
|
||||
>>> component.provideAdapter(ConceptType)
|
||||
>>> component.provideAdapter(TypeConcept)
|
||||
>>> from loops.common import NameChooser
|
||||
>>> component.provideAdapter(NameChooser)
|
||||
|
||||
>>> from loops import Loops
|
||||
>>> loopsRoot = site['loops'] = Loops()
|
||||
|
@ -185,6 +187,13 @@ Updating the concept map
|
|||
{'description': u'', 'title': u'Zope 2', 'type': '10', 'id': '16',
|
||||
'name': u'zope2'}
|
||||
|
||||
The name of the concept is checked by a name chooser; if the corresponding
|
||||
parameter is empty, the name will be generated from the title.
|
||||
|
||||
>>> xrf.createConcept(topicId, u'', u'Python')
|
||||
{'description': u'', 'title': u'Python', 'type': '10', 'id': '17',
|
||||
'name': u'python'}
|
||||
|
||||
Changing the attributes of a concept
|
||||
------------------------------------
|
||||
|
||||
|
|
|
@ -22,6 +22,7 @@ XML-RPC views.
|
|||
$Id$
|
||||
"""
|
||||
|
||||
from zope.app.container.interfaces import INameChooser
|
||||
from zope.interface import implements
|
||||
from zope.event import notify
|
||||
from zope.lifecycleevent import ObjectCreatedEvent, ObjectModifiedEvent
|
||||
|
@ -128,7 +129,9 @@ class LoopsMethods(MethodPublisher):
|
|||
def createConcept(self, typeId, name, title):
|
||||
type = getObjectForUid(typeId)
|
||||
title = toUnicode(title)
|
||||
c = self.concepts[name] = Concept(title)
|
||||
c = Concept(title)
|
||||
name = INameChooser(self.concepts).chooseName(name, c)
|
||||
self.concepts[name] = c
|
||||
c.conceptType = type
|
||||
notify(ObjectCreatedEvent(c))
|
||||
notify(ObjectModifiedEvent(c))
|
||||
|
|
Loading…
Add table
Reference in a new issue