[Cubicweb] edition of coupled relations

Sylvain Thénault sylvain.thenault at logilab.fr
Wed May 20 09:00:13 CEST 2015


On 20 mai 08:08, Sylvain Thénault wrote:
> Hi there,
> 
> given the following piece of schema:
> 
>   class keyword_scheme(RelationDefinition):
>     subject = 'SEDAKeyword'
>     object = 'ConceptScheme'
>     cardinality = '?*'
>     inlined = True
> 
> 
>   class keyword_value(RelationDefinition):
>     subject = 'SEDAKeyword'
>     object = 'Concept'
>     cardinality = '?*'
>     inlined = True
>     constraints = [RQLConstraint('S seda_keyword_scheme KS, O in_scheme KS')]

should be readen 'S keyword_scheme KS, O in_scheme KS') 

> I want a form to edit `SEDAKeyword` where I can edit both relations. As you can
> see fields are related, and AFAIK, there is currently no generic way to get
> proper behaviour in such case (i.e. vocabulary for `keyword_value` being
> properly set depending on `keyword_scheme`, whether in creation or edition of
> the `SEDAKeyword` entity). Am I missing something?
> 
> If not, do you have any idea on the best strategy to solve this? It much
> probably depends on the widgets you use in your form. In my case my default
> choice would be a simple combobox for `keyword_scheme` and a relation widget for
> `keyword_value` (provided by the eponym cube).
> 
> In this configuration, the simplest idea coming to my mind would be to provide
> to the view displaying the relation widget the form values. It could then
> either:
> 
> 1. fetch the edit controller to submit them, get the vocabulary and rollback the
>    transaction
> 
> 2. process them manually and control the generated RQL to skip part of the
>    constraint to get some information from the form data instead of the database
> 
> 1. would probably be simpler to implement, but would cause problems if the form
>    data are yet incorrect wrt schema constraints and other integrity hooks.
> 
> 2. will be hard to implement correctly I'm afraid, but we've already done
> similar things (e.g. using `__linked_to` information)
> 
> Also in the 1. case, form data submission would have to be done on each result page
> display, needing to have form data available when clicking on the navigation
> links.
> 
> All in all, I think I will attempt to get this specific case working by using
> the existing `__linked_to` information support, it should be enough provided
> some litle change to make it works in the case of entity edition as well, not
> only creation.
> 
> Any thoughs / experiences to share?
> -- 
> 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
> _______________________________________________
> Cubicweb mailing list
> Cubicweb at lists.cubicweb.org
> https://lists.cubicweb.org/mailman/listinfo/cubicweb

-- 
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