Adding field and index with a behavior

I made a behavior that adds some fields.

For one of the fields (which is a ((datagridfield) list). I want to have an index.

  1. Is there other ways of adding an index than in profiles (meaning one has to install a product) ?
  2. Does it matter much what kind of index I use (now I use FieldIndex) when the field (with dicts) looks like this:

[ {name: 'something', email: 'some@email.com', phone: '123456'}, {name: 'somet', email: 'some2@email.com', phone: '213456'}]

How are you adding this behaviour?

in a zcml file, usually like this:

<plone:behavior
        title="My behaviour"
        description="Adds fields for xxx"
        provides=".behaviors.IMyBehavior"
        for="plone.dexterity.interfaces.IDexterityContent"
        />

Ah, so you are working on the file system. In that case, why do you stipulate that adding an index shouldn't require working on the file system?

Since the behavior shows up even if a profile is notinstalled, it would be better if one does not have to install anything.

In other words: If someone adds the behavior without installing the profile, it might break the view

I looked through plone.behavior and was hoping that maybe an event would be fired as soon as a behavior is assigned, but this doesn't seem to be provided (yet). Otherwise you could have hooked into that and check for and create an index...