[Cubicweb] [CubicWeb / discussion] Improving uicfg

Vladimir Popescu vladimir.popescu at logilab.fr
Thu Dec 12 19:36:02 CET 2013


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.

2. Be able to add a callback which generates e.g. custom HTML and /
   or navigates through the paths between entities. For example:

       pvdc.add_to(('Subject', 'attributes'),
                   {'callback': 'foo', 'vid': '...', ....})

       def foo(w, entity):
           displayable_ent = entity.relation[0].attribute
           w(... displayable_ent ...)

   This facility generalizes 1, as we could specify the RQL in the
   callback. However, 1 is more explicit, as we would see the
   intention right away.

2'. As an alternative to 1 and 2 which stay true to the declarative
    spirit of uicfg, we could adopt a more programmatic stance
    and provide a PrimaryView overloading mechanism akin to what
    it's done in the views that inherit from EntityTableView:
    we can add columns which do not correspond to attribute / relation
    names in the schema, by calling, on them, user-defined callbacks
    passed as the renderfunc kwarg to EntityTableColRenderer.

3. Be able to specify a property / method defined in entities.py
   instead of the schema definitions, as in

       pvdc.add_to(('Subject', 'attributes'),
                   {'property': 'bar', ...})  

   where 'bar' is defined in entities.py for 'Subject'.

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.

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.

Best,
Vladimir



More information about the Cubicweb mailing list