# HG changeset patch # User Denis Laxalde # Date 1479206645 -3600 # Node ID ec612abc2e2ea70a48cde1faec5697bf5c93d32e # Parent a85b7a898e1303e6eae7cd0bfcc492b16ea0b248 [pyramid] Try "eid" first when retrieving a subresource of ETypeResource So that Pyramid traversal works as existing CubicWeb URL publishing. diff -r a85b7a898e13 -r ec612abc2e2e cubicweb/pyramid/resources.py --- a/cubicweb/pyramid/resources.py Tue Nov 15 12:20:02 2016 +0100 +++ b/cubicweb/pyramid/resources.py Tue Nov 15 11:44:05 2016 +0100 @@ -64,8 +64,17 @@ self.cls = vreg['etypes'].etype_class(self.etype) def __getitem__(self, value): - attrname = self.cls.cw_rest_attr_info()[0] - return EntityResource(self.request, self.cls, attrname, value) + # Try eid first, then rest attribute as for URL path evaluation + # mecanism in cubicweb.web.views.urlpublishing. + for attrname in ('eid', self.cls.cw_rest_attr_info()[0]): + resource = EntityResource(self.request, self.cls, attrname, value) + try: + rset = resource.rset + except HTTPNotFound: + continue + if rset.rowcount: + return resource + raise KeyError(value) @reify def rset(self):