How do I set a one to one relationship between a folder and a dexterity content type?

StackOverflow https://stackoverflow.com/questions/22316045

  •  12-06-2023
  •  | 
  •  

Question

I have a dexterity content type and I would like there to only ever be one of these in a folder. I cannot find any documentation to cover this. How is it accomplished?

Was it helpful?

Solution

You can add an event-listener, which applies on creation of your type and removes your type of the addable-types of its parent, like described in:

https://developer.plone.org/content/types.html#constraining-the-addable-types-per-type-instance

Consequently you probably also want to redo the setting when deleting this contenttype, by adding another event-listener for the deletion.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top