[Cubicweb] add vocabulary options in migration process

Sylvain Thénault sylvain.thenault at logilab.fr
Thu Mar 10 17:18:18 CET 2011


On 10 mars 10:15, Carlos Balderas wrote:
> Hi List!
> 
> I am trying make a migration to change a static vocabulary in an attribute
> of an entity.
> 
> I was wondering if "sync_schema_props_perms" in a migration file would do
> the work?, because I still don't get this change done.
> 
> this is the case:
> 
> frequency = String(required=True,
>                        description=_('how often this activity has to be
> done'),
>                        internationalizable=True,
>                        vocabulary=(_('daily'), _('weekly'), _('monthly'),
> _('annual')),
>                        default='daily')
> 
> and I need to add two more options: permament and biweekly.
> 
> frequency = String(required=True,
>                        description=_('how often this activity has to be
> done'),
>                        internationalizable=True,
>                        vocabulary=(_('permanent'), _('daily'), _('weekly'),
>                                    _('biweekly'), _('monthly'),
> _('annual')),
>                        default='daily')
> 
> What I did, was to make a the changes in the schema file and create a
> migration file with:
> 
> sync_schema_props_perms('ProcessStage', syncperms=False, syncprops=True,
> syncrdefs=False, commit=True)
> 
> where ProcessStage is the entity containing the attribute frecuency.
> 
> I run the migration process but the new vocabulary options are not added.
> 
> Could someone tell if this is the correct way to achieve what I need?

syncrdefs=False make it skip the entity type's attributes, hence your
vocabulary change. Either change this or use sync_schema_props_perms
given a 3-uple defining the relation as first argument, eg
(<EntityType>, 'frequency', 'String') in your case.

-- 
Sylvain Thénault                               LOGILAB, Paris (France)
Formations Python, Debian, Méth. Agiles: http://www.logilab.fr/formations
Développement logiciel sur mesure:       http://www.logilab.fr/services
CubicWeb, the semantic web framework:    http://www.cubicweb.org



More information about the Cubicweb mailing list