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

Sylvain Thénault sylvain.thenault at logilab.fr
Mon Oct 22 18:42:21 CEST 2012


On 22 octobre 17:55, Stéphane Bugat wrote:
> 
> > 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, bty, if I just want to modify the metadata of the attribute, let's say for instance add a 'maxsize' to the RichString description attribute, is it possible without removing and recreating the attribute?

That could be simple. But is not, at least until we do some work on yams api. The pb is you want to change maxsize, and not e.g. fulltextindexed.
"maxsize" argument, together with "vocabulary", are also syntactic sugar which actually add some constraints to the attribute.
The problem is that the creation api is user friendly, but not the modification one, and you ends up having to do something like

  descr_meta = Person.get_relation('description_format')
  descr_meta.constraints = [SizeConstraint(newsize)] # suppose you don't have any other constraint

This will work but is definitly not satisfying.

Following this dicussion and the principles of least surprise, I propose to add two 
tickets on the yams project:

* when an attribute is deleted, its meta attributes should be deleted as well

* handle maxsize and vocabulary at schema building time and not before, so
  one can modify building objects using same vocab as for creation
 
-- 
Sylvain Thénault, LOGILAB, Paris (01.45.32.03.12) - Toulouse (05.62.17.16.42)
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