[Cubicweb] ORMHelper registry

Adrien Di Mascio adrien.dimascio at logilab.fr
Tue Mar 8 20:30:09 CET 2011


Hi everyone,

Currently, we use *fetch_attrs* to improve attribute cache control and 
*fetch_order* to control how data should be sorted. This has proven to 
be very useful and easy to use.

However, in some complex cases, I'd like to be able to give more complex 
hints to the ORM. For instance, I might like to :

- fetch different attributes according to the relation being traversed 
(not only according to destination type)

- use RQL functions to change fetch_order

- sort according to "composed entities" (e.g. if schema defines "A rel1 
B", "B rel2 (composite) C", I might want A.related('rel1') to sort 
according to C)

- fetch other relations and other attributes that CubicWeb has no chance 
to guess

- anything fancy


I would define and register such helpers in a custom registry, they 
could define selectors, etc. etc. The ORMHelper interface would be 
something like::

     class MyHelper(ORMHelper):
         __select__ = something()

         def fetch_attrs(self):
             return [xxx]
         def fetch_order(self, rql):
             return some_transformed(rql)

I haven't give a lot of thoughts on the API actually, this is just a 
concept I'd like to be discussed.

Any thoughts ?
-- 
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/


More information about the Cubicweb mailing list