# HG changeset patch # User Sylvain Thénault # Date 1296132229 -3600 # Node ID 449e5b46ed3defd9f1ad9fd11c5b37591bcab164 # Parent 5f13aefb470bab6904ec5819310e9e46048a206c [component] refactor layout retrieval to handle case where we've an entity without rset properly diff -r 5f13aefb470b -r 449e5b46ed3d web/component.py --- a/web/component.py Thu Jan 27 13:42:51 2011 +0100 +++ b/web/component.py Thu Jan 27 13:43:49 2011 +0100 @@ -294,16 +294,18 @@ self.call(**kwargs) return getlayout = self._cw.vreg['components'].select + layout = getlayout('layout', self._cw, **self.layout_select_args()) + layout.render(w) + + def layout_select_args(self): try: # XXX ensure context is given when the component is reloaded through # ajax context = self.cw_extra_kwargs['context'] except KeyError: context = self.cw_propval('context') - layout = getlayout('layout', self._cw, rset=self.cw_rset, - row=self.cw_row, col=self.cw_col, - view=self, context=context) - layout.render(w) + return dict(rset=self.cw_rset, row=self.cw_row, col=self.cw_col, + view=self, context=context) def init_rendering(self): """init rendering callback: that's the good time to check your component @@ -388,6 +390,11 @@ entity = self.cw_rset.get_entity(self.cw_row or 0, self.cw_col or 0) self.entity = entity + def layout_select_args(self): + args = super(EntityCtxComponent, self).layout_select_args() + args['entity'] = self.entity + return args + @property def domid(self): return domid(self.__regid__) + unicode(self.entity.eid)