[Cubicweb] UI configuration : evolution proposal

Florent Cayré fcayre at logilab.fr
Wed Jul 18 18:02:10 CEST 2012


Hi list,

as can be seen in this ticket <https://www.cubicweb.org/ticket/2406609>, 
I would like to be able to use the powerful uicfg 
<http://docs.cubicweb.org/devweb/rtags.html#the-uicfg-module> module 
more widely to configure my user interfaces.

The problem to me is that the configurations (be it for forms, primary 
views, a.s.o) apply site-wide. You just can't hide one field of a form 
to a user and show it to the site managers using uicfg. Same with 
primary view parts.

The way I tried to solve this problem is putting ui configuration 
instances into a dedicated registry and make them selectable. Then I 
turned direct imports from the default configuration into selection in 
this registry and that was it.

If you have another idea to implement this, please share. This email is 
precisely aimed at getting feedback on this solution and choose another 
approach if anyone in the CW community has a better plan.

To give you a better idea, here is the kind of code you will need to 
write once the corresponding patch 
<https://www.cubicweb.org/patch/2398503> applied (note it depends on 
this one <http://www.logilab.org/patch/98633> in logilab.common) to 
build a new configuration instance:

* my_cube/uicfg.py::

   from cubicweb.web import uicfg

   class MyCubeUserAfs(uicfg.AutoformSectionRelationTags):
       __select__ = uicfg.AutoformSectionRelationTags.__select__ & 
match_user_groups('users')

   my_cube_users_afs = MyCubeUserAfs()

* my_cube/views/uicfg.py::

   from my_cube.uicfg import my_cube_users_afs

my_cube_users_afs.tag_object_of(('MyInstanceType1', 'my_rel', 
'MyInstanceType2'), 'main', 'hidden')


The reason for splitting this into two files is for automatic reloading 
in debug mode : you will be able to edit your configuration rules in 
debug mode without restarting your server (however if you edit 
my_cube/uicfg.py, you will have to restart).

The uihelper 
<http://docs.cubicweb.org/devweb/rtags.html#the-uihelper-module> module 
functions have been added an optional configuration instance as a 
parameter, but should probably become methods of the configuration 
classes instead.

Waiting for you feedback,
Cheers,
Florent Cayré.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cubicweb.org/pipermail/cubicweb/attachments/20120718/d930e26d/attachment-0164.html>


More information about the Cubicweb mailing list