diff --git a/browser/resource.py b/browser/resource.py
index 2050bd5..afe32f5 100644
--- a/browser/resource.py
+++ b/browser/resource.py
@@ -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
diff --git a/configure.zcml b/configure.zcml
index ac4651b..a4400f4 100644
--- a/configure.zcml
+++ b/configure.zcml
@@ -460,13 +460,14 @@
name="loops.PredicateSource" />
+
+
+
-
-
-
+
diff --git a/xmlrpc/README.txt b/xmlrpc/README.txt
index ac56119..8086e60 100755
--- a/xmlrpc/README.txt
+++ b/xmlrpc/README.txt
@@ -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
------------------------------------
diff --git a/xmlrpc/common.py b/xmlrpc/common.py
index 00c9a6d..b188e60 100644
--- a/xmlrpc/common.py
+++ b/xmlrpc/common.py
@@ -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))