[Cubicweb] [CubicWeb / discussion] Improving uicfg

Denis Laxalde denis.laxalde at logilab.fr
Wed Dec 18 08:07:41 CET 2013


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.




More information about the Cubicweb mailing list