Skip to content

Review the initialisation of the Selector class

  • It should be easy to initialize a selector also there is no data in the request.var
  • The user case can be found in track_publications/graph/dashboard
  • The current code:
    cfg = Storage()
    cfg.Graph_selectorCumulative = 'True'
    cfg.Graph_selectorId = ''
    cfg.Graph_selectorId_authors_roles = ''
    cfg.Graph_selectorId_graphs = ''
    cfg.Graph_selectorId_projects = ''
    cfg.Graphs_selectorId_teams = ''
    cfg.Graph_selectorTime = T('month')
    cfg.Graph_selectorYear_start = datetime.now().year
    cfg.Graph_selectorYear_end = ''

    request.vars.update(cfg)

    fields = ('cumulative','id_graphs', 'time', 'year_start','year_end')
    selector = Selector(virtdb.graph_selector, exclude_fields=fields)

should become:

    fields = ('cumulative','id_graphs', 'time', 'year_start','year_end')
    selector = Selector(virtdb.graph_selector, exclude_fields=fields)
    selector.year_start = datetime.now().year
    selector.cumulative = True