[Cubicweb] Pyramid and REST

Christophe de Vienne christophe at unlish.com
Tue Jun 9 11:55:50 CEST 2015


Le 08/06/2015 15:06, Christophe de Vienne a écrit :
> 
> 
> Le 08/06/2015 14:03, Rabah Meradi a écrit :
>> On Wed, 2015-06-03 at 09:38 +0200, Christophe de Vienne wrote:
>>> I just had a quick look.
>>>
>>> We need to define a standard route for entities, that match
>>> /etype/*traverse. The nature of the context has to be discussed, as we
>>> have different options to explore.
>>> This route would used by any view that work on the etypes or entities,
>>> including your 'delete' view.
>>>
>>> I think this route should be defined in pyramid-cubicweb, so any cube
>>> can add views on it.
>>
>> Is it possible to use pyramid traversal for this? I don't know if it's
>> possible otherwise, but to use all the power of the pyramid traversal we
>> must adapt our resources. In our case add the __getitem__ method to the
>> entity object. 
> 
> Yes it is possible to use pyramid traversal, and I think we should do it.
> 


I made a first patch to demonstrate what I have in mind for routing all
the /etype/xxx urls.

https://www.cubicweb.org/patch/5450580

It is the first step for removing the urlpublishing & controllers from
cubicweb and convert them to pyramid views.

The ultimate goal is to remove the need of bwcompat completely. For the
remaining hard to change cases (editcontroller I guess), we should be
able to directly call the controller from a pyramid view.

One of the things that will change with this new approach, and that
needs to be studied closely, is the way 'rql=' and 'vid=' can be passed
along.

In pyramid, with traversal routes, the view name is passed in the url,
just after the context has been found (for ex, /etype/eid/edit -> the
edit view).

As for the 'rql=' parameter, I think it should be restricted to a
specific route (/rql ?), which would be a traversal route too, allowing
various views to be used (/rql/etypelist, etc).

Actions will need some thinking too, static files should be more
straighforward.

Note that this is the start of breaking the urls compatibility, so we
must be careful, and try making the path as painless as possible.

Cheers,

Christophe



More information about the Cubicweb mailing list