Cannot create an object with a custom naming behavior
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 101
- Forks
- 62
- Avg merge
- 15h 15m
- Merged PRs (30d)
- 1
Description
Because of these lines:
derived_id = id or title
new_id = chooser.chooseName(derived_id, content)
I will never reach line 34 (nameFromTitle = INameFromTitle(obj, None)) here
https://github.com/plone/plone.app.content/blob/9c220b2ceace9c74a464529d89e4a66c16c0fc17/plone/app/content/namechooser.py#L34
For this reason it is not possible to create with plone.api an object that authomatically gets the id correctly from a custom INameFromTitle behavior that is not based on the title.
I noticed this with a custom INameFromTitle adapter that gives an id based on the date, but I think this is an issue also for the File content type (which uses this behavior: https://github.com/plone/plone.app.dexterity/blob/184184150ab6b7743769fe92bf8ec78e5fb52873/plone/app/dexterity/behaviors/filename.py#L16)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in plone.api/src/plone/api/content.py around the derived_id and chooser.chooseName calls, then compare it with plone.app.content/namechooser.py at line 34 and the filename behavior referenced in plone.app.dexterity. Trace how custom INameFromTitle adapters are selected during creation. Done means plone.api can create objects whose id is supplied by a custom naming behavior, including the reported File case.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100