web/views/plots.py
branchtls-sprint
changeset 742 99115e029dca
parent 0 b97547f5f1fa
child 1132 96752791c2b6
equal deleted inserted replaced
739:39721e56b56d 742:99115e029dca
     1 import os
     1 import os
     2 
     2 
     3 from logilab.common import flatten
     3 from logilab.common import flatten
     4 
     4 
       
     5 from cubicweb.vregistry import objectify_selector
     5 from cubicweb.web.views import baseviews
     6 from cubicweb.web.views import baseviews
     6 
     7 
       
     8 @objectify_selector
     7 def plot_selector(cls, req, rset, *args, **kwargs):
     9 def plot_selector(cls, req, rset, *args, **kwargs):
     8     """accept result set with at least one line and two columns of result
    10     """accept result set with at least one line and two columns of result
     9     all columns after second must be of numerical types"""
    11     all columns after second must be of numerical types"""
    10     if rset is None:
    12     if rset is None:
    11         return 0
    13         return 0
    32         id = 'plot'
    34         id = 'plot'
    33         title = _('generic plot')
    35         title = _('generic plot')
    34         binary = True
    36         binary = True
    35         content_type = 'image/png'
    37         content_type = 'image/png'
    36         _plot_count = 0
    38         _plot_count = 0
    37         __selectors__ = (plot_selector,)
    39         __select__ = plot_selector()
    38 
    40 
    39         def call(self, width=None, height=None):
    41         def call(self, width=None, height=None):
    40             # compute dimensions
    42             # compute dimensions
    41             if width is None:
    43             if width is None:
    42                 if 'width' in self.req.form:
    44                 if 'width' in self.req.form: