# HG changeset patch # User Sylvain Thénault # Date 1316762257 -7200 # Node ID 287813c487b790fecdf54b4c32baf95ad66ec487 # Parent 58f696c0f5b33c18aa8cea5c65ac98998dd2d5d6 [breadcrumbs] keep proper breadcrumbs when creating an entity linked to another by inspecting __linkto (closes #1947476) diff -r 58f696c0f5b3 -r 287813c487b7 web/views/ibreadcrumbs.py --- a/web/views/ibreadcrumbs.py Thu Sep 22 16:12:33 2011 +0200 +++ b/web/views/ibreadcrumbs.py Fri Sep 23 09:17:37 2011 +0200 @@ -28,7 +28,8 @@ from cubicweb import tags, uilib from cubicweb.entity import Entity from cubicweb.selectors import (is_instance, one_line_rset, adaptable, - one_etype_rset, multi_lines_rset, any_rset) + one_etype_rset, multi_lines_rset, any_rset, + match_form_params) from cubicweb.view import EntityView, EntityAdapter from cubicweb.web.views import basecomponents # don't use AnyEntity since this may cause bug with isinstance() due to reloading @@ -120,7 +121,10 @@ # XXX support kwargs for compat with other components which gets the view as # argument def render(self, w, **kwargs): - entity = self.cw_rset.get_entity(0, 0) + try: + entity = self.cw_extra_kwargs['entity'] + except KeyError: + entity = self.cw_rset.get_entity(0, 0) adapter = ibreadcrumb_adapter(entity) view = self.cw_extra_kwargs.get('view') path = adapter.breadcrumbs(view) @@ -190,6 +194,17 @@ w(u'') +class BreadCrumbLinkToVComponent(BreadCrumbEntityVComponent): + __select__ = basecomponents.HeaderComponent.__select__ & match_form_params('__linkto') + + def render(self, w, **kwargs): + eid = self._cw.list_form_param('__linkto')[0].split(':')[1] + entity = self._cw.entity_from_eid(eid) + ecmp = self._cw.vreg[self.__registry__].select( + self.__regid__, self._cw, entity=entity, **kwargs) + ecmp.render(w, **kwargs) + + class BreadCrumbView(EntityView): __regid__ = 'breadcrumbs'