[Erp5-report] r20206 - /experimental/Experimental/patches/

nobody at svn.erp5.org nobody at svn.erp5.org
Sat Mar 29 12:48:12 CET 2008


Author: bartek
Date: Sat Mar 29 12:48:11 2008
New Revision: 20206

URL: http://svn.erp5.org?rev=20206&view=rev
Log:
renamed patch because it contains many things

Added:
    experimental/Experimental/patches/ERP5Form_ListBox_bells_and_whistles.py
      - copied unchanged from r20010, experimental/Experimental/patches/ERP5Form_ListBox_line_marking.py
Removed:
    experimental/Experimental/patches/ERP5Form_ListBox_line_marking.py

Removed: experimental/Experimental/patches/ERP5Form_ListBox_line_marking.py
URL: http://svn.erp5.org/experimental/Experimental/patches/ERP5Form_ListBox_line_marking.py?rev=20205&view=auto
==============================================================================
--- experimental/Experimental/patches/ERP5Form_ListBox_line_marking.py (original)
+++ experimental/Experimental/patches/ERP5Form_ListBox_line_marking.py (removed)
@@ -1,322 +1,0 @@
-##############################################################################
-#
-# Copyright (c) 2008 ERP5 Polska Sp. z o.o. All Rights Reserved.
-#                    Mikolaj Antoszkiewicz <mikolaj at erp5.pl>
-#
-# WARNING: This program as such is intended to be used by professional
-# programmers who take the whole responsability of assessing all potential
-# consequences resulting from its eventual inadequacies and bugs
-# End users who are looking for a ready-to-use solution with commercial
-# garantees and support are strongly adviced to contract a Free Software
-# Service Company
-#
-# This program is Free Software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
-#
-##############################################################################
-
-"""
-   THIS CODE CONTAINS IN FACT TWO PATCHES
-   (becaue it is rather difficult to apply two monkey patches to the same method...)
-   =================================================================================
-   1. ListBox line marking
-
-   This patch creates a new field in listbox formulator form.
-   It allows entering of the script name, which in turn should return a name
-   (or names separated by spaces) of the css class(es). They would be usually 
-   based on some conditions related to the objects listed in that listbox.
-   The css class should be defined separately and added (preferably dynamicaly)
-   to the erp5.css style sheet.
-   In combination with the erp5_core_experimental BT (rev. >= 19770) for each 
-   listbox line where script returns the css class name(s), it is added to that
-   line default css class ('DataA' or 'DataB').
-
-   RATIONALE: this is a very handy functionality, since it allows besides
-   filtering to mark items of special meaning/importance. It is already used 
-   with success in eg. Thunderbird for marking mail messages.
-
-   2. Boxover
-
-   This, in combination with erp5_xhtml_experimental, shows additional data about
-   a listbox object in a nice "boxover" which pops up onmouseover.
-
-   RATIONALE: to impress clients, and to let a user get more detailed information (which
-   normally wouldn't fit into one line) without clicking too much and reloading page
-   many times.
-
-   CONFIGURATION: in listbox definition, either define Boxover columns OR put a Boxover script
-   which should return a dict with 'header', 'body' and optionally many other values (see
-   boxover.swazz.org for more).
-
-   TODO: make it Ajax-based to make it lazy.
-"""
-     
-from Products.Formulator.DummyField import fields
-from Products.ERP5Form.ListBox import lazyMethod
-from Products.CMFCore.utils import getToolByName
-
-from zLOG import LOG, INFO
-
-
-from Products.ERP5Form.ListBox import ListBoxWidget 
-
-ListBoxWidget.marking_method = fields.StringField('marking_method',
-                        	    		title="Marking Method",
-                          				description=('Name of script colorizing listbox lines.'),
-                          				default='',
-                          				required=0) 
-ListBoxWidget.property_names.append('marking_method')
-
-ListBoxWidget.boxover_columns = fields.ListTextAreaField('boxover_columns',
-                                 title="Boxover Columns",
-                                 description=(
-        "A list of attributes to be shown in boxover (the first item will be used as boxover title). Can be overwritten by Boxover Method."),
-                                 default=[],
-                                 required=0)
-ListBoxWidget.property_names.append('boxover_columns')
-
-ListBoxWidget.boxover_method = fields.StringField('boxover_method',
-                        	    		title="Boxover Method",
-                          				description=('Name of script returning parameters for Boxover display.'),
-                          				default='',
-                          				required=0) 
-ListBoxWidget.property_names.append('boxover_method')
-
-
-from Products.ERP5Form.ListBox import ListBoxRenderer
-
-def getMarkingMethodName(self):
-      """Returns ers match
-      """
-      marking_method = self.field.get_value('marking_method')
-      try:
-        name = getattr(marking_method, 'method_name')
-      except AttributeError:
-        name = marking_method
-      return name or None
-
-ListBoxRenderer.getMarkingMethodName = lazyMethod(getMarkingMethodName)
-
-
-def getMarkingMethod(self):
-      """Return the marking method object.
-      """
-      marking_method_name = self.getMarkingMethodName()
-  
-      if marking_method_name is not None:
-        try:
-          marking_method = getattr(self.getContext(), marking_method_name)
-        except AttributeError, KeyError:
-          marking_method = None
-      else:
-        marking_method = None
- 
-      return marking_method
- 
-ListBoxRenderer.getMarkingMethod = lazyMethod(getMarkingMethod)
-
-def getBoxoverMethodName(self):
-      """Returns ers match
-      """
-      boxover_method = self.field.get_value('boxover_method')
-      try:
-        name = getattr(boxover_method, 'method_name')
-      except AttributeError:
-        name = boxover_method
-      return name or None
-
-ListBoxRenderer.getBoxoverMethodName = lazyMethod(getBoxoverMethodName)
-
-
-def getBoxoverMethod(self):
-      """Return the boxover method object in the context of data object.
-      """
-      boxover_method_name = self.getBoxoverMethodName()
-  
-      if boxover_method_name is not None:
-        try:
-          boxover_method = getattr(self.getContext(), boxover_method_name)
-        except AttributeError, KeyError:
-          boxover_method = None
-      else:
-        boxover_method = None
- 
-      return boxover_method
- 
-ListBoxRenderer.getBoxoverMethod = lazyMethod(getBoxoverMethod)
-
-
-def ListBoxRenderer_query(self):
-      """Get report sections and construct a list of lines. Note that this method has a side
-      effect in the selection, and the renderer object itself.
-      """
-      start = self.getLineStart()
-      max_lines = self.getMaxLineNumber()
-      report_section_list = self.getReportSectionList()
-      param_dict = self.getParamDict()
-      translation_service = getToolByName(self.getContext(), 'Localizer', None) # for boxover labels which are translated here
-
-      # Set the total number of objects.
-      self.total_size = sum([s.object_list_len for s in report_section_list])
-
-      # Calculuate the start and the end offsets, and set the page numbers.
-      if max_lines == 0:
-        end = self.total_size
-        self.total_pages = 1
-        self.current_page = 0
-      else:
-        self.total_pages = int(max(self.total_size - 1, 0) / max_lines) + 1
-        if start >= self.total_size:
-          start = max(self.total_size - 1, 0)
-        start -= (start % max_lines)
-        self.current_page = int(start / max_lines)
-        end = min(start + max_lines, self.total_size)
-        param_dict['list_start'] = start
-        param_dict['list_lines'] = max_lines
-        selection = self.getSelection()
-        selection.edit(params = param_dict)
-
-      # Make a list of lines.
-      line_class = self.getLineClass()
-      line_list = []
-
-      try:
-        section_index = 0
-        current_section_base_index = 0
-        current_section = report_section_list[0]
-        current_section_size = current_section.object_list_len
-        for i in range(start, end):
-          # Make sure we go to the right section.
-          while current_section_base_index + current_section_size <= i:
-            current_section_base_index += current_section_size
-            section_index += 1
-            current_section = report_section_list[section_index]
-            current_section_size = current_section.object_list_len
-
-          offset = i - current_section_base_index + current_section.offset
-          if current_section.is_summary:
-            index = None
-          elif self.isReportTreeMode():
-            index = offset
-          else:
-            index = i
-
-          marking_method = self.getMarkingMethod()
-          if marking_method is not None:
-            marking_css = marking_method(current_section.object_list[offset].getObject())
-          else:
-            marking_css = ''
-
-          boxover = self.renderBoxover(current_section.object_list[offset].getObject(), translation_service)
-
-          #LOG('ListBox', 0, 'current_section.__dict__ = %r' % (current_section.__dict__,))
-          line = line_class(renderer = self,
-                            obj = current_section.object_list[offset],
-                            index = index,
-                            is_summary = current_section.is_summary,
-                            context = current_section.context,
-                            is_open = current_section.is_open,
-                            selection_domain = current_section.selection_domain,
-                            depth = current_section.depth,
-                            domain_title = current_section.domain_title,
-                            marking_css = marking_css,
-                            boxover = boxover)
-          line_list.append(line)
-      except IndexError:
-        # If the report section list is empty, nothing to do.
-        pass
-
-      return line_list
-
-ListBoxRenderer.query = ListBoxRenderer_query
-
-
-def ListBoxRenderer_renderBoxover(self, ob, translation_service):
-  # render title to generate a boxover for the line
-  def renderBoxoverLine(line):
-    # XXX should the rendering and translation be moved to ListBox_asHTML?
-    # translate column label
-    label = translation_service.translate('ui', line[1]).encode('utf8')
-    # get data in a similar way to normal listbox cells
-    # XXX should be improved and refactored so as to remove code duplication
-    editable_field = self.getEditableField(line[0])
-    if editable_field is not None:
-      tales = editable_field.tales.get('default', '')
-      if tales:
-        prop = editable_field.__of__(ob).get_value('default', cell=ob)
-    else:
-      _marker = []
-      prop = ob.getProperty(line[0], _marker)
-      if prop is _marker:
-        try:
-          prop = getattr(ob, line[0])
-        except AttributeError:
-          prop = ''
-      if callable(prop):
-        try:
-          prop = prop()
-        except (AttributeError, KeyError, Unauthorized):
-          prop = 'N/A'
-    if prop is None: prop = ''
-    return '<b>%s: </b>%s' % (label, prop)
-  data = {}
-  boxover_method = self.getBoxoverMethod()
-  # if there is a method (script) we use this
-  if boxover_method is not None: 
-    data = boxover_method(ob)
-    return ' '.join(['%s=[%s]' % item for item in data.items()])
-  else: # render from columns
-    boxover_column_list = self.field.get_value('boxover_columns')
-    if len(boxover_column_list) > 0:
-      data['header'] = renderBoxoverLine(boxover_column_list[0])
-      line_list = []
-      for item in boxover_column_list[1:]:
-        line_list.append(renderBoxoverLine(item))
-      data['body'] = '<br/>'.join(line_list)
-  return ' '.join(['%s=[%s]' % item for item in data.items()])
-
-ListBoxRenderer.renderBoxover = ListBoxRenderer_renderBoxover
-
-
-from Products.ERP5Form.ListBox import ListBoxRendererLine
-
-def ListBoxRendererLine___init__(self, renderer = None, obj = None, index = 0, is_summary = False, context = None,
-                 is_open = False, selection_domain = None, depth = 0, domain_title=None, marking_css = '', boxover = None):
-      """In reality, the object is a brain or a brain-like object.
-      """
-      self.renderer = renderer
-      self.obj = obj
-      self.index = index
-      self.is_summary = is_summary
-      self.context = context
-      self.is_open = is_open
-      self.selection_domain = selection_domain
-      self.depth = depth
-      self.domain_title = domain_title
-      self.marking_css = marking_css
-      self.boxover = boxover
-
-def ListBoxRendererLine_getMarkingCssName(self):
-      """Return name of css used for marking listbox line.
-      """
-      return self.marking_css
-
-def ListBoxRendererLine_getBoxover(self):
-      """Return boxover string to be used as line's title
-      """
-      return self.boxover
-
-ListBoxRendererLine.__init__ = ListBoxRendererLine___init__
-ListBoxRendererLine.getMarkingCssName = ListBoxRendererLine_getMarkingCssName
-ListBoxRendererLine.getBoxover = ListBoxRendererLine_getBoxover




More information about the Erp5-report mailing list