I defined some content types based on Plone Dexterity, I want any content type has his own ID. So I used the zope.schema.Id .
class IArticle(form.Schema, IImageScaleTraversable):
"""
Article
"""
form.model("models/article.xml")
id = schema.Id(
title=_(u"Identifier"),
description=_(u"The unique identifier of object."),
required=False
)
When I create a new article object, it works fine, but when I want to modify the Id of an existed article, It always show me error:
{'args': (<MultiContentTreeWidget 'form.widgets.IRelatedItems.relatedItems'>,),
'context': <Article at /dev/articles/this-is-another-articles>,
'default': <object object at 0x100266b20>,
'loop': {},
'nothing': None,
'options': {},
'repeat': {},
'request': <HTTPRequest, URL=http://localhost:8083/dev/articles/this-is-another-article/@@edit>,
'template': <zope.browserpage.viewpagetemplatefile.ViewPageTemplateFile object at 0x10588ecd0>,
'view': <MultiContentTreeWidget 'form.widgets.IRelatedItems.relatedItems'>,
'views': <zope.browserpage.viewpagetemplatefile.ViewMapper object at 0x10b309f50>}
.......
.......
.......
Module zope.tales.expressions, line 217, in __call__
Module zope.tales.expressions, line 211, in _eval
Module plone.formwidget.contenttree.widget, line 147, in render_tree
Module plone.app.layout.navigation.navtree, line 186, in buildFolderTree
Module Products.CMFPlone.CatalogTool, line 427, in searchResults
Module Products.ZCatalog.ZCatalog, line 604, in searchResults
Module Products.ZCatalog.Catalog, line 907, in searchResults
Module Products.ZCatalog.Catalog, line 656, in search
Module Products.ZCatalog.Catalog, line 676, in sortResults
Module plone.app.folder.nogopip, line 104, in documentToKeyMap
Module plone.folder.ordered, line 102, in getObjectPosition
Module plone.folder.default, line 130, in getObjectPosition
ValueError: No object with id "this-is-another-articles" exists.
I don't think this is a use-case supported in the stock Edit form. You can rename items from the folder contents tab of the folder containing the item. Should you want to do this from the edit form:
Maybe something like (completely untested):
I've achieved this with a custom add form so that only the add form includes id-field and the edit form doesn't (renaming is done in the old way through the rename-action or from the folder contents view).
Some boilerblate:
There's also an open issue and preliminary work for it to make Dexterity-types support the standard "Show 'Short Name' on content?"-feature.
for use with dexterity content types, i adapted @spdupton's answer (correcting a typo in the import) and changing self.context to self.request
#