[Cubicweb] Modification of attributes of entities already in the scheme

Sylvain Thénault sylvain.thenault at logilab.fr
Mon Oct 22 17:36:16 CEST 2012

On 22 octobre 17:25, Stéphane Bugat wrote:
> Dear all,

Hi Stéphane,
> I'd like to modify some attributes of the entities imported in my scheme through the other cubes. For instance, let's suppose I'd like to transform the 'description' attribute of the Person entity into a simple String and not a RichString, with a maximum size.
> I've tried the following:
>    from cubes.person.schema import Person
>    Person.remove_relation('description')
>    Person.add_relation(String(required=False,
>            fulltextindexed=True,
>            description=_('Description'),
>            maxsize=300),
>        name='description',)
> But this does not seems to work at all, although no error is raised. How do I have to proceed?

This is because RichString is a kind of "virtual" attribute, which will actually ends up in
two attributes, e.g. description and description_format. So you should remove both (though
removing description_format may be enough for your case).
Sylvain Thénault, LOGILAB, Paris ( - Toulouse (
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