web/views/plots.py
changeset 8190 2a3c1b787688
parent 7919 ae3307cac44e
child 10609 e2d8e81bfe68
equal deleted inserted replaced
8189:2ee0ef069fa7 8190:2a3c1b787688
     1 # copyright 2003-2011 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
     1 # copyright 2003-2012 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
     2 # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
     2 # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
     3 #
     3 #
     4 # This file is part of CubicWeb.
     4 # This file is part of CubicWeb.
     5 #
     5 #
     6 # CubicWeb is free software: you can redistribute it and/or modify it under the
     6 # CubicWeb is free software: you can redistribute it and/or modify it under the
    20 __docformat__ = "restructuredtext en"
    20 __docformat__ = "restructuredtext en"
    21 _ = unicode
    21 _ = unicode
    22 
    22 
    23 from logilab.common.date import datetime2ticks
    23 from logilab.common.date import datetime2ticks
    24 from logilab.common.deprecation import class_deprecated
    24 from logilab.common.deprecation import class_deprecated
       
    25 from logilab.common.registry import objectify_predicate
    25 from logilab.mtconverter import xml_escape
    26 from logilab.mtconverter import xml_escape
    26 
    27 
    27 from cubicweb.utils import UStringIO, json_dumps
    28 from cubicweb.utils import UStringIO, json_dumps
    28 from cubicweb.appobject import objectify_selector
    29 from cubicweb.predicates import multi_columns_rset
    29 from cubicweb.selectors import multi_columns_rset
       
    30 from cubicweb.web.views import baseviews
    30 from cubicweb.web.views import baseviews
    31 
    31 
    32 @objectify_selector
    32 @objectify_predicate
    33 def all_columns_are_numbers(cls, req, rset=None, *args, **kwargs):
    33 def all_columns_are_numbers(cls, req, rset=None, *args, **kwargs):
    34     """accept result set with at least one line and two columns of result
    34     """accept result set with at least one line and two columns of result
    35     all columns after second must be of numerical types"""
    35     all columns after second must be of numerical types"""
    36     for etype in rset.description[0]:
    36     for etype in rset.description[0]:
    37         if etype not in ('Int', 'BigInt', 'Float'):
    37         if etype not in ('Int', 'BigInt', 'Float'):
    38             return 0
    38             return 0
    39     return 1
    39     return 1
    40 
    40 
    41 @objectify_selector
    41 @objectify_predicate
    42 def second_column_is_number(cls, req, rset=None, *args, **kwargs):
    42 def second_column_is_number(cls, req, rset=None, *args, **kwargs):
    43     etype = rset.description[0][1]
    43     etype = rset.description[0][1]
    44     if etype not  in ('Int', 'BigInt', 'Float'):
    44     if etype not  in ('Int', 'BigInt', 'Float'):
    45         return 0
    45         return 0
    46     return 1
    46     return 1
    47 
    47 
    48 @objectify_selector
    48 @objectify_predicate
    49 def columns_are_date_then_numbers(cls, req, rset=None, *args, **kwargs):
    49 def columns_are_date_then_numbers(cls, req, rset=None, *args, **kwargs):
    50     etypes = rset.description[0]
    50     etypes = rset.description[0]
    51     if etypes[0] not in ('Date', 'Datetime', 'TZDatetime'):
    51     if etypes[0] not in ('Date', 'Datetime', 'TZDatetime'):
    52         return 0
    52         return 0
    53     for etype in etypes[1:]:
    53     for etype in etypes[1:]: