Author: jmorliaguet Date: Fri Oct 28 02:36:12 2005 New Revision: 28762 Modified: z3lab/cpsskins/branches/jmo-perspectives/browser/rendering/engine.py Log:
- implemented 2-step update / render Modified: z3lab/cpsskins/branches/jmo-perspectives/browser/rendering/engine.py ============================================================================== --- z3lab/cpsskins/branches/jmo-perspectives/browser/rendering/engine.py (original) +++ z3lab/cpsskins/branches/jmo-perspectives/browser/rendering/engine.py Fri Oct 28 02:36:12 2005 @@ -142,7 +142,8 @@ contexts['perspective'] = perspective # build the tree and store it in the request - contexts['tree'] = _buildTreeInfo(node=element, perspective=perspective) + contexts['tree'] = _buildTreeInfo(node=element, request=request, + perspective=perspective) def __call__(self, **kw): element = self.element @@ -155,12 +156,10 @@ contexts['template'] = kw.get('template') contexts['engine'] = kw.get('engine', 'default') - # TODO update the tree nodes - # render the tree return getMultiAdapter((element, request), IRenderer)(**kw) -def _buildTreeInfo(index={}, node=None, perspective=None): +def _buildTreeInfo(index={}, node=None, request=None, perspective=None): """Build the tree info for an element. """ node_index = index[node.identifier] = {} @@ -175,11 +174,24 @@ children = INodeTraverser(node).getChildNodes(display=display, perspective=perspective) - node_index['display'] = display + info = ContextInfo( + {'element': node, + 'display': display, + 'request': request, + 'data': None, + 'metadata': None, + }) + node_index['children'] = children + node_index['info'] = info + + update = IUpdateData(node, None) + if update is not None: + update(info) for child in children: - _buildTreeInfo(index=index, node=child, perspective=perspective) + _buildTreeInfo(index=index, node=child, request=request, + perspective=perspective) return index @@ -205,13 +217,7 @@ engine = contexts['engine'] # set local context info variables - info = ContextInfo( - {'element': element, - 'display': element_info['display'], - 'request': request, - 'data': None, - 'metadata': None, - }) + info = element_info['info'] rendered = [] if ILeaf.providedBy(element): @@ -233,11 +239,10 @@ if (iface, engine) not in renderer_registry: logger.log(INFO, "The element '%s' cannot be rendered by the '%s' engine." - % (repr(element), engine) - ) + % (repr(element), engine)) return rendered - display = element_info['display'] + display = info['display'] # apply all filters for f in self._getFilters(iface, display, engine): rendered = f(rendered, info, **kw) -- http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins