[Cubicweb] Error while defining a relation
sylvain.thenault at logilab.fr
Thu Jul 7 16:00:32 CEST 2011
On 07 juillet 15:32, Dominique GEFFROY wrote:
> In fact, what I really wanted to do is to add this relation has_file
> to all the entity type of my schema that all derive from the same
> entity type.
> Let's say I have a parent entity type class A and several entity
> type class B, C, etc that all derive directly or not from class A.
> I first tried to to give A as the subject of the relation but then I
> got an error when I tried to add this relation to an entity of type
> B for example. The error was about incompatible types and I supposed
> that the relation was not inherited in the subclasses of A. That's
> why I used "*" to add the relation to all the entity types, I don't
> know if there is a better way to do so ?
if you define this relation in class A (using SubjectRelation),
then all subclasses will have it.
Else, you can also explicitly list all entity types that should
have it as 'subject'
> Anyway, I thought I had to define at least the cardinality of the
> relation because it is "*" ( each entity can have several has_file
> relations) and it seems that the default cardinality is "1". I
> actually tried to define the relation with only subject and object
> attributes but then I got entities with only one has_file
> relation... And when I add the cardinality attribute in the
> relation, I have the reported error about the composite attribute...
> Does it mean that I should create an entity for the object of the
> relation ? If a relation with String as object is automatically an
> attribute relation, maybe it is not possible to have a cardinality
> different from 1 in such relation ?
yep, attribute relations can only have ? or 1 cardinality. We should
have an error when trying to do otherwise. When you want multiple
values, you currently have to define an entity type.
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