Easily editable vocabularies?

Hello. I'm in a team of new Plone developers in a federal institution and we're currently learning the ins and outs of Plone 5.
We are having a problem with vocabularies.
We need to provide a vocabulary with profession names for a list field. At the moment, our vocabulary is created from all the object with a "Profession" type. We are doing this because it's easy for newbie users to add and remove professions.
Here's the problem. Say we have a content type named "Profession List" and it has a title and a List field of all professions for you to choose. With Plone 5.0.4, the list field shows as empty when a user is CREATING a Profession List object but it shows all professions normally when a user is EDITING it.

Is there a better way to create easily and intuitively editable vocabularies? Can this weird list bug be solved?

Al the very best,
Gabriel Antunes

Please provide some code or screenshots...hard to understand what you are doing.

1 Like

Hi, Gabriel

What you seem to need is the (afaik) still unexisting port of Products.ATVocabularyManager to Dexterity. There's an option but I'm not sure it'd fit your usecase (I didn't try it):

A simpler version would be creating a Site Setup configlet to store the professions with a simple textarea or a more complex custom widget. You could provide easy access to selected users using group portlets. See (but avoid the Grok approach):

I don't think the professions are going to be updated very often, are they? All site users will be able to update them or just a selected few?

1 Like

recently I had a similar problem, just that i had to provide a vocabulary for a subtree of the site.
On the node that defines the subtree I added a behavior like this:

@provider(IFormFieldProvider)
class ISponsorVocabularyDefiniton(model.Schema):
    """Behavior providing fields to define a sponsor vocabulary.
    """
    widget('sponsor_categories', TextLinesFieldWidget)
    sponsor_categories = schema.List(
        title=_(u'label_sponsor_categories', default=u'Sponsor Categories'),
        description=_(
            u'help_sponsor_categories',
            default=u'Categories to be used in this Sponsors Folder. '
                    u'One per Line! '
        ),
        required=False,
        value_type=schema.TextLine(),
    )

and then I defined a vocabulary like so:

@provider(IContextSourceBinder)
def sponsor_categories(context):
    terms = [SimpleVocabulary.createTerm('', '--empty--', _('(unset)'))]
    # SimpleVocabulary.createTerm(value, token, label)
    container = None
    for obj in context.aq_chain:
        if ISponsorVocabularyDefiniton.providedBy(obj):
            container = obj
            break
    if container:
        adapter = ISponsorVocabularyDefiniton(container)
        for label in adapter.sponsor_categories or []:
            terms.append(
                SimpleVocabulary.createTerm(
                    label,
                    label.encode('ascii', errors='ignore'),
                    label
                )
            )
    return SimpleVocabulary(terms)

which I then used in a behavior on the contained items:

    sponsor_type = schema.Choice(
        title=_(u'label_sponsor_type', default=u'Sponsor Category'),
        source=sponsor_categories,
        required=False,
        missing_value='',
    )
    widget('sponsor_type', SelectFieldWidget)

I hope you can derive a working solution for your problem from this input.

1 Like

There's no code. Everything can be done with the GUI alone so far. Basically what we need is guarantee that users won't type anything unusual in some fields.

These links are really helpful, especially the second one. I can't thank you enough.

Some of them will be updated fairly often by a few users. Vocabularies are for us to guarantee that people won't make associations with jobs/people/notices that don't exist. We have to make sure the fields are filled with valid information, that's all.[quote="jensens, post:4, topic:2469"]
I hope you can derive a working solution for your problem from this input.
[/quote]
That and some documentation snooping will be very useful. Thanks!

1 Like