(self)
return self._blocks
Returns all the blocks of the story.
Returns all the blocks of the story.
Returns all the blocks of the story .
def blocks(self):
        """Returns all the blocks of the story."""
        if not self._blocks:
            story_data = self.lazyload_data(refresh_cache=True)
            objects = story_data.get('objects')
            content = ''
            if objects:
                content = objects[0].get('content', [])
            index = 0
            for content_block in json.loads(content):
                name = content_block.get('componentName', '')
                if content_block.get('content'):
                    block = TextBlock(self, index)
                    block.from_dict(content_block)
                elif name == 'TsViewEventList':
                    block = ViewBlock(self, index)
                    block.from_dict(content_block)
                    search_obj = search.Search(sketch=self._sketch)
                    search_obj.from_saved(block.view_id)
                    block.feed(search_obj)
                elif name == 'TsAggregationCompact':
                    block = AggregationBlock(self, index)
                    block.from_dict(content_block)
                    agg_obj = aggregation.Aggregation(self._sketch)
                    agg_obj.from_saved(block.agg_id)
                    block.feed(agg_obj)

                    # Defaults to a table view.
                    if not block.chart_type:
                        block.chart_type = 'table'
                elif name == 'TsAggregationGroupCompact':
                    block = AggregationGroupBlock(self, index)
                    block.from_dict(content_block)
                    group_obj = aggregation.AggregationGroup(self._sketch)
                    group_obj.from_saved(block.group_id)
                    block.feed(group_obj)
                self._blocks.append(block)
                index += 1
        return self._blocks
def blocks ( self ) : if not self . _blocks : story_data = self . lazyload_data ( refresh_cache = True ) objects = story_data . get ( 'objects' ) content = '' if objects : content = objects [ 0 ] . get ( 'content' , [ ] ) index = 0 for content_block in json . loads ( content ) : name = content_block . get ( 'componentName' , '' ) if content_block . get ( 'content' ) : block = TextBlock ( self , index ) block . from_dict ( content_block ) elif name == 'TsViewEventList' : block = ViewBlock ( self , index ) block . from_dict ( content_block ) search_obj = search . Search ( sketch = self . _sketch ) search_obj . from_saved ( block . view_id ) block . feed ( search_obj ) elif name == 'TsAggregationCompact' : block = AggregationBlock ( self , index ) block . from_dict ( content_block ) agg_obj = aggregation . Aggregation ( self . _sketch ) agg_obj . from_saved ( block . agg_id ) block . feed ( agg_obj ) # Defaults to a table view. if not block . chart_type : block . chart_type = 'table' elif name == 'TsAggregationGroupCompact' : block = AggregationGroupBlock ( self , index ) block . from_dict ( content_block ) group_obj = aggregation . AggregationGroup ( self . _sketch ) group_obj . from_saved ( block . group_id ) block . feed ( group_obj ) self . _blocks . append ( block ) index += 1 return self . _blocks