Commit dcbd6127 authored by Jérome Perrin's avatar Jérome Perrin

use getProperty instead of getPreference on the preference tool for caching.

wrap lines to 80 chars


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@5575 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 417d9bd1
...@@ -43,8 +43,8 @@ def create_settings_form(): ...@@ -43,8 +43,8 @@ def create_settings_form():
report_method = fields.StringField( report_method = fields.StringField(
'report_method', 'report_method',
title='Report Method', title='Report Method',
description=('The method to get a list of items (object, form, parameters) ' description=('The method to get a list of items (object, form,'
'to aggregate in a single Report'), ' parameters) to aggregate in a single Report'),
default='', default='',
required=0) required=0)
...@@ -111,7 +111,8 @@ class ERP5Report(ERP5Form): ...@@ -111,7 +111,8 @@ class ERP5Report(ERP5Form):
# Special Settings # Special Settings
settings_form = create_settings_form() settings_form = create_settings_form()
def __init__(self, id, title, unicode_mode=0, encoding='UTF-8', stored_encoding='UTF-8'): def __init__(self, id, title, unicode_mode=0,
encoding='UTF-8', stored_encoding='UTF-8'):
"""Initialize form. """Initialize form.
id -- id of form id -- id of form
title -- the title of the form title -- the title of the form
...@@ -203,7 +204,6 @@ class ReportSection: ...@@ -203,7 +204,6 @@ class ReportSection:
In ReportTree listbox display mode, you can override : In ReportTree listbox display mode, you can override :
selection_report_path, the root category for this report selection_report_path, the root category for this report
selection_report_list, the list of unfolded categories (defaults to all) selection_report_list, the list of unfolded categories (defaults to all)
""" """
self.path = path self.path = path
...@@ -261,19 +261,23 @@ class ReportSection: ...@@ -261,19 +261,23 @@ class ReportSection:
portal_selections = context.portal_selections portal_selections = context.portal_selections
selection_list = [self.selection_name] selection_list = [self.selection_name]
if self.form_id and hasattr(context[self.form_id], 'listbox') : if self.form_id and hasattr(context[self.form_id], 'listbox') :
selection_list += [ context[self.form_id].listbox.get_value('selection_name') ] selection_list += [
# save report's selection and orignal form's selection, as ListBox will overwrite it context[self.form_id].listbox.get_value('selection_name') ]
# save report's selection and orignal form's selection,
#as ListBox will overwrite it
for selection_name in selection_list : for selection_name in selection_list :
if selection_name is not None : if selection_name is not None :
if not self.saved_selections.has_key(selection_name) : if not self.saved_selections.has_key(selection_name) :
self.saved_selections[selection_name] = {} self.saved_selections[selection_name] = {}
if self.selection_report_list is not None: if self.selection_report_list is not None:
selection = portal_selections.getSelectionFor(selection_name, REQUEST=REQUEST) selection = portal_selections.getSelectionFor(selection_name,
REQUEST=REQUEST)
self.saved_selections[selection_name]['report_list'] = \ self.saved_selections[selection_name]['report_list'] = \
selection.getReportList() selection.getReportList()
selection.edit(report_list=self.selection_report_list) selection.edit(report_list=self.selection_report_list)
if self.selection_report_path is not None: if self.selection_report_path is not None:
selection = portal_selections.getSelectionFor(selection_name, REQUEST=REQUEST) selection = portal_selections.getSelectionFor(selection_name,
REQUEST=REQUEST)
self.saved_selections[selection_name]['report_path'] = \ self.saved_selections[selection_name]['report_path'] = \
selection.getReportPath() selection.getReportPath()
selection.edit(report_path=self.selection_report_path) selection.edit(report_path=self.selection_report_path)
...@@ -288,23 +292,26 @@ class ReportSection: ...@@ -288,23 +292,26 @@ class ReportSection:
selection_name=selection_name) selection_name=selection_name)
if self.selection_params is not None: if self.selection_params is not None:
self.saved_selections[selection_name]['params'] = \ self.saved_selections[selection_name]['params'] = \
portal_selections.getSelectionParams(selection_name, REQUEST=REQUEST) portal_selections.getSelectionParams(
selection_name, REQUEST=REQUEST)
portal_selections.setSelectionParamsFor(selection_name, portal_selections.setSelectionParamsFor(selection_name,
self.selection_params, REQUEST=REQUEST) self.selection_params, REQUEST=REQUEST)
if self.selection_columns is not None: if self.selection_columns is not None:
self.saved_selections[selection_name]['columns'] = \ self.saved_selections[selection_name]['columns'] = \
portal_selections.getSelectionColumns(selection_name, REQUEST=REQUEST) portal_selections.getSelectionColumns(selection_name,
portal_selections.setSelectionColumns(selection_name, self.selection_columns,
REQUEST=REQUEST) REQUEST=REQUEST)
portal_selections.setSelectionColumns(selection_name,
self.selection_columns, REQUEST=REQUEST)
if self.selection_sort_order is not None: if self.selection_sort_order is not None:
self.saved_selections[selection_name]['sort_order'] = \ self.saved_selections[selection_name]['sort_order'] = \
portal_selections.getSelectionSortOrder(selection_name, REQUEST=REQUEST) portal_selections.getSelectionSortOrder(selection_name,
portal_selections.setSelectionSortOrder(selection_name, self.selection_sort_order,
REQUEST=REQUEST) REQUEST=REQUEST)
portal_selections.setSelectionSortOrder(selection_name,
self.selection_sort_order, REQUEST=REQUEST)
portal_pref = context.getPortalObject().portal_preferences portal_pref = context.getPortalObject().portal_preferences
for pref, value in self.preferences.items() : for pref, value in self.preferences.items() :
self.saved_preferences[pref] = portal_pref.getPreference(pref) self.saved_preferences[pref] = portal_pref.getProperty(pref)
portal_pref.setPreference(pref, value) portal_pref.setPreference(pref, value)
security.declarePublic('popReport') security.declarePublic('popReport')
...@@ -319,17 +326,22 @@ class ReportSection: ...@@ -319,17 +326,22 @@ class ReportSection:
portal_selections = context.portal_selections portal_selections = context.portal_selections
selection_list = [] selection_list = []
if self.form_id and hasattr(context[self.form_id], 'listbox') : if self.form_id and hasattr(context[self.form_id], 'listbox') :
selection_list += [ context[self.form_id].listbox.get_value('selection_name') ] selection_list += [
context[self.form_id].listbox.get_value('selection_name') ]
selection_list += [self.selection_name] selection_list += [self.selection_name]
# restore report then form selection # restore report then form selection
for selection_name in selection_list: for selection_name in selection_list:
if selection_name is not None: if selection_name is not None:
if self.selection_report_list is not None: if self.selection_report_list is not None:
selection = portal_selections.getSelectionFor(selection_name, REQUEST=REQUEST) selection = portal_selections.getSelectionFor(
selection.edit(report_list = self.saved_selections[selection_name]['report_list']) selection_name, REQUEST=REQUEST)
selection.edit(report_list =
self.saved_selections[selection_name]['report_list'])
if self.selection_report_path is not None: if self.selection_report_path is not None:
selection = portal_selections.getSelectionFor(selection_name, REQUEST=REQUEST) selection = portal_selections.getSelectionFor(
selection.edit(report_path = self.saved_selections[selection_name]['report_path']) selection_name, REQUEST=REQUEST)
selection.edit(report_path =
self.saved_selections[selection_name]['report_path'])
if self.listbox_display_mode is not None: if self.listbox_display_mode is not None:
# XXX Dirty fix, to be able to change the display mode in form_view # XXX Dirty fix, to be able to change the display mode in form_view
REQUEST.list_selection_name = selection_name REQUEST.list_selection_name = selection_name
...@@ -339,7 +351,8 @@ class ReportSection: ...@@ -339,7 +351,8 @@ class ReportSection:
selection_name=selection_name) selection_name=selection_name)
if self.selection_params is not None: if self.selection_params is not None:
# first make sure no parameters that have been pushed are erased # first make sure no parameters that have been pushed are erased
portal_selections.setSelectionParamsFor(selection_name, {}, REQUEST=REQUEST) portal_selections.setSelectionParamsFor(selection_name,
{}, REQUEST=REQUEST)
# then restore the original params # then restore the original params
portal_selections.setSelectionParamsFor(selection_name, portal_selections.setSelectionParamsFor(selection_name,
self.saved_selections[selection_name]['params'], self.saved_selections[selection_name]['params'],
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment