plone / plone/plone.api

content.create needs title or id

Open
#295 8 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
101
Forks
62
Avg merge
15h 15m
Merged PRs (30d)
1

Description

the @at_least_one_of('id', 'title') decorator for plone.api.content.create does not allow to create objects of types that do not have a title field.

>>> api.content.create(folder, 'my.person', firstname="Scott", lasname="Tiger")
MissingParameterError: At least one of these parameters must be supplied: id, title.

i think it's a common pattern to compute the title out of other attributes such as first and lastname of a person:

class IPerson(model.Schema):

    firstname = schema.TextLine(
        title=u'Firstname',
        required=True,
    )

    lastname = schema.TextLine(
        title=u'Lastname',
        required=True,
    )

@implementer(IPerson)
class Person(Container):

    @property
    def title(self):
        return self.lastname + " " + self.firstname

    @title.setter
    def title(self, value):
        pass

any objections on removing the decorator or ideas on how to support title-less types too?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the @at_least_one_of('id', 'title') decorator and the plone.api.content.create entry point mentioned in the issue. Read the comment thread for the unresolved decision about removing the requirement or supporting title-less types. Done means the intended validation is defined and covered for content types whose title is derived from other attributes.

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.