LinesField on dexterity

Does dexterity has something similar to AT LinesField. I'm creating a container content type where you can define a list of items to use on the item inside a child choice object. I did it many years ago with AT, any project doing something similar in dexterity?

Wouldn't a namedvocabulary work here, or do you require the values to be editable ttw? Depending on your needs, you could store the values in the portal registry.

https://docs.plone.org/develop/plone/forms/vocabularies.html

I'm trying to do it TTW so each section/dept can define their own vocabulary for the section, then that list will be used as a choice in a field in the child object.

right now I'm creating new content types in my add-on for each section which are 99% identical except for the vocabulary, but that's not very efficient

Example: (not with list - but using members of site for making vocab - but principle same)

@provider(IVocabularyFactory)
def dynamic_doctor(context):
    acl_users = getToolByName(context, 'acl_users')
    hospital_doctors_group = context.HOSPITAL_DOCTORS_GROUP()
    group = acl_users.getGroupById(hospital_doctors_group)
    terms=[]

    if group:
        members = group.getGroupMembers()
        for member in members:
            memberid = member.getId()
            fullname = member.getProperty( 'fullname', memberid )
            terms.append(
                    SimpleVocabulary.createTerm(
                    memberid,
                    memberid,
                    fullname
                                               )
                            )
    return SimpleVocabulary(terms)

    responsibleDoctor = schema.Choice(
        title=_(u"danbiopatient_label_responsibleDoctor", default=u"Responsible doctor"),
        required=False,
        description=_(u''),
        vocabulary='dynamic_doctor'
    )


zcml for the vocab:

      <utility
    name="dynamic_doctor"
    component="danbio.registry.content.schemas.dynamic_vocabularies.dynamic_doctor"
/>

I have something similar with users and another with content. (see below)
but I was thinking more in the lines of "image handling" and "site settings" but for the container and item in the addon that the reviewer for the dept/section can modify.

"image handling" and "site settings":


Screen Shot 2020-04-07 at 2.38.44 PM

Creating Vocabulary from catalog query:

# -*- coding: utf-8 -*-

from plone import api
from zope.interface import implementer
from zope.schema.interfaces import IVocabularyFactory
from zope.schema.vocabulary import SimpleTerm
from zope.schema.vocabulary import SimpleVocabulary

@implementer(IVocabularyFactory)
class AvailableUnitGoals(object):
"""
"""

def __call__(self, context):
    results = []
    get_container_unit = '/'.join(context.getPhysicalPath()[:-1])
    unit = api.content.get(path=get_container_unit).define_unit
    brains = api.content.find(
        portal_type='unit_goal',
        sort_on='sortable_title',
        unit=unit
    )
    brains_unique = []
    for brain in brains:
        if brain.unit_goal not in brains_unique:
            brains_unique.append(brain.unit_goal)
    for brain in brains_unique:
        results.append(
            SimpleTerm(
                value=brain,
                title=brain,
            )
        )

    # Create a SimpleVocabulary from the terms list and return it:
    return SimpleVocabulary(results)


AvailableUnitGoalsFactory = AvailableUnitGoals()

An instance of a class with just one __call__ is an anti-pattern, because a function is the same and much easier to read.

But anyway, the interesting part is the code inside and that you have context available. But be aware, context on add is the container, while on edit it is the content itself.