[Cubicweb] [CubicWeb / discussion] Improving uicfg

Vincent Michel vincent.michel at logilab.fr
Wed Dec 18 09:48:59 CET 2013


On 18/12/2013 08:07, Denis Laxalde wrote:
> Vladimir Popescu a écrit :
>> On 13/12/2013 08:07, Sylvain Thénault wrote:
>>> On 12 décembre 19:36, Vladimir Popescu wrote:
>>> 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).
>
> Considering the two parts of your answer, it also seems to me that a 
> contextual component (CtxComponent) would nicely handle the display of 
> your 'my_computed_attribute' alongside the primary view of your main 
> entity. E,g.:
>
> class MyComputedAttributeComponent(EntityCtxComponent):
>   __select__ = (EntityCtxComponent.__select__ &
>                 is_instance('YourMainEntity'))
>   context = 'navcontentbottom'
>   title = _('This mimics a computed attribute')
>
>   def render_body(self, w):
>      [implement rendering here or call an existing view]
>
> Cheers,
> Denis.
One of the use case is  to include in the attributes a simple link as:

    <a href="my request +  rql + vid">See all related XXX</a>

The issue with a CtxComponent is that you cannot include it in the 
rendering of the attributes or the rendering of the relations. Moreover, 
it is a bit complicated if you only want to add a link (in this case, I 
rather prefer to define a specific primary view).

Best,

Vincent
>
> _______________________________________________
> Cubicweb mailing list
> Cubicweb at lists.cubicweb.org
> http://lists.cubicweb.org/mailman/listinfo/cubicweb




More information about the Cubicweb mailing list