[Cubicweb] Understanding _cw

Christophe de Vienne christophe at unlish.com
Fri May 16 13:57:37 CEST 2014


Le 16/05/2014 10:22, Sylvain Thénault a écrit :
> On 16 mai 10:05, Christophe de Vienne wrote:
>> The most simple solution is to separate in 2 or 3 attributes/params.
>> - cw for config, reg and repo, because it is all the instance-wide objects
>> - cnx when a connection but no request is needed.
>> - request when a request is needed.
> sounds good, though I would rephrase the two last points: 
> - cnx when a connection to the repo is established
> - request when the originator is an HTTP request
>
> Take care that in some case, we'll have to process an HTTP request without a
> connection being established (eg register/lost password form for site where
> anonymous are not allowed).
A request exists before it is linked to a cnx, and even any repo or
config (at the very early stage of handling it).

The case of the views remains unclear to me. A cnx feels not enough (am
I wrong on that ?), and a request way too much : we should be able to
use views outside the handling of http requests.

>> The request object could have a 'cnx' attribute.
>> We could even have a 'cw' attribute on cnx, removing the need for a cw
>> argument when calling appobjects.
> This is not clear to me. Currently the cw is an argument mostly because of it
> being the request object.

Well, removing the cw argument and have it as an attribute on request
would make the api more pyramid-like.



Christophe



More information about the Cubicweb mailing list