[Cubicweb] Error while defining a relation

Dominique GEFFROY dominique.geffroy at cea.fr
Thu Jul 7 15:32:45 CEST 2011


Thank you for your answer.

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 ?

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 ?

Dominique

Sylvain Thénault a écrit :
> On 07 juillet 12:29, GEFFROY Dominique INSERM wrote:
>   
>> Dear Cubicweb experts,
>>
>> I'm trying to define a new schema for a cube but I get an error about a RelationDefinition that I don't understand.
>>
>> Here is my RelationDefinition:
>>
>> class has_file(RelationDefinition):
>>     subject = "*"
>>     object = 'String'
>>     cardinality='**'
>>     composite="subject"
>>
>> And here is the error while creating a database for an instance of the cube:
>>
>> Initializing the system database
>> --------------------------------
>>     
> [snip]
>   
>>   File "/usr/lib/python2.6/dist-packages/cubicweb/web/uicfg.py", line 438, in init_actionbox_appearsin_addmenu
>>     if not rdef.role_cardinality(role) in '?1' and rdef.composite == role:
>> AttributeError: 'RelationDefinitionSchema' object has no attribute 'composite'
>>
>> I don't understand why it complains about this composite attribute, I defined it in my class. Did I do something wrong ?
>>     
>
> The error doesn't help... The pb is that you add an attribute (since object='String')
> relation to every possible entity types (do you really want this ?), while the
> 'composite' relation property is only available for non-attribute relation.
>
> Try:
>
>   class has_file(RelationDefinition):
>      subject = "*"
>      object = 'String'
>
>
>   

-- 

Dominique Geffroy - IFR49

CEA/SAC/DSV/I2BM/NeuroSpin
Bât 145, Point Courrier 156
91191 GIF/YVETTE, FRANCE
Tel +33 (0) 1 69 08 94 80
Fax +33 (0) 1 69 08 78 55
 




More information about the Cubicweb mailing list