[Cubicweb] Entity._cw nature

Aurélien Campéas aurelien.campeas at logilab.fr
Tue Jul 8 10:47:33 CEST 2014

On 07/07/2014 23:36, Christophe de Vienne wrote:
> Hi,
> I am having trouble with self._cw inside an Entity method.
> When called from a web request, it is a TwistedRequest (or something
> close), an when called from a worker task, it is a InternalSession.
> When I need to access the repo attribute, or get an internal_session (or
> just deactivate security temporary) I have to check what I am dealing with.
> The same issue will arise when using views from a task.

See http://lists.cubicweb.org/pipermail/cubicweb/2014-May/001838.html
("understanding _cw") and the following discussion.

> Since this is related to the web request/cnx distinction, I would like
> to know if the ongoing work in 3.21 will do something about it ?


*This* is the cnx / request divorce issue.

> If it doesn't, how about saying that self._cw, in Entity and hooks at
> least, but maybe also in views, should always be a cnx ?
> How much code would it break ?

Doing it for entities and hooks wouldn't break much code but
I'm pretty *sure* it would break some, but nothing irremediable.

I'm all for doing an experiment on this.

For views it's more complicated.


More information about the Cubicweb mailing list