[Cubicweb] ORMHelper registry

Adrien Di Mascio adrien.dimascio at logilab.fr
Wed Mar 9 09:23:00 CET 2011


Hi,

On 09/03/2011 08:57, Sylvain Thénault wrote:
> On 09 mars 08:30, Adrien Di Mascio wrote:

>> but then what if the RQL function takes 2 parameters ? One being the
>> corresponding attribute, the other being another attribute or worse
>> an attribute fetched on a linked entity (typically a linked by a
>> composite relation).
>
> I ask you the question : then what?

Well, then ... how would I do be able to do that with the current API ?

> IMO there are two different things:
>
> * moving api to control order and fetched attributes away from entity,
>    and into an adapter to make this easily overridable per entity (and more,
>    such as relation being traversed as you told earlier)

+1. I'm not sure I would prefer an adapter over a new decicated 
registry. Is:

   db_entity = entity.cw_adapt_to('OrmEntity')
   rset = db_entity.related('my_relation')
   # or: entities = db_entity.my_relation

the kind of thing you're thinking of ?

This would remove ``related()`` from entity's API. It would probably be 
a good thing per se but i fear it would be painful to write because 
``related()`` is used __so often__ ...


> * extending this api to allow more control

+1.

> Each point being desirable :)

+2 then.

-- 
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