[Cubicweb] Higher-level API for rtags

Adrien Di Mascio adrien.dimascio at logilab.fr
Fri Sep 24 19:54:06 CEST 2010


Dear CubicWeb fellows,

In a client application, being tired of using the lengthy and verbose 
uicfg syntax/API, I ended up with defining higher-level helpers.

A few examples::

   # form uicfg helpers
   hide_fields(etype, fieldnames) # 'hidden' tag

   set_field_kwargs(etype, fieldname, label=label,
                    widget=MyWidget())

   set_fields_order(etype, fieldnames) # 'order' property

   edit_inline(etype, fieldname) # inlined forms
   edit_as_attr(etype, rtype) # edit 'rtype' in the 'attr' section


   # actionxbox uicfg helpers
   append_to_addmenu(etype, rtypes)
   remove_from_addmenu(etype, rtypes)


For "complex" cases, I also tried a class-based declarative API :

class MyFormConfig(FormConfig):
     ###### I'd like selectors here ;-) #####
     etype = 'MyEtype'
     # hide 'attr1', 'attr5' and 'attr6'
     hidden = ('attr1', 'attr5', 'attr6')
     # modify default order
     field_order = ('attr4', 'attr2', 'attr3')
     # change default widgets of some relations
     widgets = dict(
         attr2=MyWidget(),
         attr4=MyOtherWidget())


I think that most of examples below are clear enough and I don't have to 
explain in details what they actually do. You'll find as an attachment 
the underlying implementation for more details (disclaimer: I don't 
claim the API to be absolutely consistent nor exhaustive for the moment).


My questions then are :

- Would you like to see this (maybe reworked) go into CW itself ?
- If yes, which API : the functions-based one ? The FormConfig-based
   one ? Both ?
- If, no : do you find the rtags API sexy enough or is it just my API
   that doesn't fit your brain ;-) ?


Regards.
-- 
Adrien Di Mascio - LOGILAB, Paris (France).
Tél: 01.45.32.03.12
Formations - http://www.logilab.fr/formations
Développements - http://www.logilab.fr/services
Gestion de connaissances - http://www.cubicweb.org/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: uihelpers.py
Type: text/x-python
Size: 4325 bytes
Desc: not available
URL: <http://lists.cubicweb.org/pipermail/cubicweb/attachments/20100924/9e11aecc/attachment-0251.py>


More information about the Cubicweb mailing list