[Cubicweb] [CubicWeb / discussion] Improving uicfg

Vladimir Popescu vladimir.popescu at logilab.fr
Tue Dec 17 16:09:51 CET 2013


Hi,

On 13/12/2013 08:07, Sylvain Thénault wrote:
> On 12 décembre 19:36, Vladimir Popescu wrote:
>> Dear CubicWeb developers / users,
>>
>> In using uicfg to customize a primary view, we have been
>> faced with the need to add to uicfg information which is
>> not present in the schema.
>>
>> We have encountered three basic use cases:
>>
>> 1. Be able to add RQL-computed rsets, e.g.
>>        pvdc.add_to(('Subject', 'attributes'),
>>                    {'rql': 'DISTINCT Any X WHERE ...'
>>                            '<restrictions on X>...',
>>                     'vid': '...', 'label': '...'}),
>>
>>    or
>>        pvdc.add_to(('Subject', 'attributes'),
>>                    {'rql': 'Any COUNT(X) WHERE ...'
>>                     '<restrictions on X>...', ...})
>>
>>    where 'X' is implicitly the Subject. Here, we would use
>>    'attributes' or 'relations', depending on the nature of
>>    the computed rset.
> I don't get the meaning of .add_to(('Subject', 'attributes'), would you precise
> the arguments and the expected effect ?

.add_to would be actually written rather as:

    pvdc.add_to(('Subject', 'my_computed_attribute'), 'attributes', {...}).

The expected effect is adding 'my_computed_attribute' to the 'Subject''s
attributes, where 'my_computed_attribute' is calculated from the rset
obtained from the query given via the 'rql' kwarg.

>
> At a first glance, I'm not keen on adding ways to add such information using
> uicfg since uicfg are already complicated while being all about schema
> annotation. I'm not sure I would like them to be something else than that.
>
> Are you aware that ContextualComponent may be used to build part of a primary
> view ? Eg either left/right box or even a section below or above
> attributes/relations section of the primary view.

Yes, although I am not very well versed in their usage.
On the other hand, I would just like to be able to make it by directly
customizing the primary view, without ContextualComponents (without
left/right boxes).

>
>> Another issue is the fact that subjects / objects are ignored in
>> tag_object_of / tag_subject_of respectively. This poses problems
>> when e.g. in tag_object_of we have subjects of several types and
>> we want to apply specific views on them.
>>
>> A soulutin is to create several views with the same regid and
>> apply appropriate selectors which would handle the different
>> entity types. But this seems less declarative to me than just
>> being able not to ignore the subjects / objects
>> as mentioned above.
> True, though that's expected that you can't do anything using the uicfg's
> declarative way, and that you sometimes have to override the default primary
> view. You're use-case are valid and should be investigated. So you should first
> show us how you implement them currently, then we shall propose better way using
> or not uicfg/API improvments.
Currently, I basically create two different views with the same regid,
but different selectors, that is, is_instance applied on different
entity types. For example, suppose I have 'MySubject' and I want to
customize its primary view. Let us also assume that 'MySubject' is
related to 'MyObject1' and 'MyObject2' etypes, as:

MyObject1 my_relation MySubject
MyObject2 my_relation MySubject.

Thus, I create two views, both with the regid 'my_object1-2-view', but
one view with a select on is_instance('MyObject1') and the other view
with a select on is_instance('MyObject2'). Besides this, each view has
its own code.

Then, I just do:

    pvdc.tag_object_of(('*', 'my_relation', 'MySubject'), {'vid':
'my_object1-2-view'})

I would like to have this behavior explicitly customizable in uicfg.

>
>> I would like to discuss on the opportunity of
>> implementing these improvements / tackling these issues.
>> A start could be to decide which tickets to add
>> to the CW project.
> start a new CWEP http://www.cubicweb.org/card/cwepindex :)
>
Yes, I think that, after a few more rounds of discussions, it would be a
good idea :-)

Best,
Vladimir



More information about the Cubicweb mailing list