def update_subtree_cacheable(self): if self.cacheable: subtree_cacheable = all( child.subtree_cacheable for child in get_direct_element_children(self)) if not self.subtree_cacheable == subtree_cacheable: self.subtree_cacheable = subtree_cacheable self.put()
def _handle_recursive(request, node, mapper, content_type, use_cache): logging.info('Handling node: %s' % node) cache_key = _should_cache(request, node, content_type, use_cache) if cache_key: mapped_response = _check_cache(cache_key) if mapped_response: if content_type == HTML_MIME: # This is a rendered template fragment. mapped_response = mark_safe(mapped_response) return mapped_response else: logging.info('Cache miss') node_processor = _get_node_view(request, node) # Processing happens bottom-up, children first... mapped_child_responses = [] for child in get_direct_element_children(node): mapped_child_response = _handle_recursive( request, child, mapper, content_type, use_cache) mapped_child_responses.append(mapped_child_response) # ...then the current node. node_response = node_processor(request, node) # The node processing step can return a value stops the normal # page rendering system, in cases where a Node can handle a POST # request, for instance. if isinstance(node_response, NodeResponseRedirect): raise InterruptPageProcessing(node_response) mapped_response = mapper( request, node, node_response, mapped_child_responses) if cache_key: _set_cache(cache_key, mapped_response) return mapped_response