I'm working with a programmer to use Plone API to create new content on the plone site. The content I want to create is a new instance of a custom product i am creating.
My question is how to do this for a custom content type. Can I define endpoint (I think that is the correct term) in my content type such that i can use the Plone API (create a new API element) to create a new instance of the content type (including title, content, etc.)??
Based on what I've seen, I believe (2) can't be done without adding to the API.
Seems the basic question is my assumption above correct: will how have to add to the API?
Note: I know from past experience i can create new instance of content type from Word document by using a parser and custom code to create CT. however, API seems much smoother.
Wayne Glover via Plone Community wrote at 2023-6-14 00:11 +0000:
...
2) My question is how to do this for a custom content type. Can I define endpoint (I think that is the correct term) in my content type such that i can use the Plone API (create a new API element) to create a new instance of the content type (including title, content, etc.)??
Plone delegates the construction of the content object to the respective
type (more precisely TypeInformation).
When you look at the API code (--> plone.api.content.create),
you see that the construction is performed via container.invokeFactory(type, content_id, **kwargs).
This looks up the type (information) object and calls its constructInstance to get the content object constructed.
Thus, defining your custom type, you can precisely control
how to create your content objects.
dexterity content types typically use plone.dexterity.fti.DexterityFTI
as type (information). The corresponding constructInstance
is implemented in Products.CMFCore.TypesTool.TypeInformation.constructInstance.
This delegates to Products.CMFCore.TypesTool.FactoryTypeInformation._constructInstance.
There, you will find details how to provide your own content
object construction.