[Cubicweb] Understanding _cw

Christophe de Vienne christophe at unlish.com
Thu May 15 21:03:08 CEST 2014

Le 15/05/2014 09:49, Aurélien Campéas a écrit :
> On 15/05/2014 09:25, Denis Laxalde wrote:
>> aurélien campéas a écrit :
>>> Whatever the future holds for _cw, I'd very much like it were re-cast as
>>> just 'cw'.
>> At this point, using a descriptive name wouldn't hurt.
> Yes it would. "cubicweb_god_object" is descriptive but too long.

It depends : it you want to keep the magic "cw" object, yes it would hurt.

But if we split cw, it would not :

self.appli -> The application, giving access to the vreg and a few
instance-related api (build_url for example).
self.cnx -> the connexion to the repo (data access, transaction
self.orm or self.dbsession -> the orm related apis, given that we
removed 'get_entity' from rset.
self.request -> the http request, for controllers

Not all appobjects would have all these attributes :

Hooks : appli & cnx
entities, sobjects and views : appli, cnx & orm
controllers : appli, cnx, orm and request

Note that I have a feeling that views should not need an access to the
request, although in many cases it can be easier to have it.



More information about the Cubicweb mailing list