[Cubicweb] ORMHelper registry
aurelien.campeas at gmail.com
Tue Mar 8 20:38:36 CET 2011
2011/3/8 Adrien Di Mascio <adrien.dimascio at logilab.fr>
> 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
this is not (yet) very palatable to me
any example ?
> - 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
> - fetch other relations and other attributes that CubicWeb has no chance to
> - 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
> 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 ?
Sounds good. It occurred to me recently that we might want fetch_attrs to
behave differently depending on the context (showing stuff in primary or
other views, in import/export process, etc.), so your proposal fits nicely
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Cubicweb