Commit 2f54ba04 authored by Yoshinori Okuji's avatar Yoshinori Okuji

Fix some dynamic patches. They should not create new classes.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@3565 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent cccbd8cd
...@@ -49,19 +49,7 @@ from Products.Formulator.Field import Field ...@@ -49,19 +49,7 @@ from Products.Formulator.Field import Field
from zLOG import LOG from zLOG import LOG
class ERP5Field(Field): def get_value(self, id, **kw):
"""
The ERP5Field provides here, request,
container etc. names to TALES expressions. It is used to dynamically
patch the standard Formulator
"""
security = ClassSecurityInfo()
# this is a field
is_field = 1
security.declareProtected('Access contents information', 'get_value')
def get_value(self, id, **kw):
"""Get value for id.""" """Get value for id."""
# FIXME: backwards compat hack to make sure tales dict exists # FIXME: backwards compat hack to make sure tales dict exists
if not hasattr(self, 'tales'): if not hasattr(self, 'tales'):
...@@ -138,15 +126,16 @@ class ERP5Field(Field): ...@@ -138,15 +126,16 @@ class ERP5Field(Field):
return value return value
def om_icons(self): psyco.bind(get_value)
def om_icons(self):
"""Return a list of icon URLs to be displayed by an ObjectManager""" """Return a list of icon URLs to be displayed by an ObjectManager"""
icons = ({'path': self.icon, icons = ({'path': self.icon,
'alt': self.meta_type, 'title': self.meta_type},) 'alt': self.meta_type, 'title': self.meta_type},)
return icons return icons
psyco.bind(get_value)
def _get_default(self, key, value, REQUEST): def _get_default(self, key, value, REQUEST):
if value is not None: if value is not None:
return value return value
try: try:
...@@ -167,9 +156,9 @@ class ERP5Field(Field): ...@@ -167,9 +156,9 @@ class ERP5Field(Field):
# Dynamic Patch # Dynamic Patch
Field.get_value = ERP5Field.get_value Field.get_value = get_value
Field._get_default = ERP5Field._get_default Field._get_default = _get_default
Field.om_icons = ERP5Field.om_icons Field.om_icons = om_icons
# Constructors # Constructors
......
...@@ -26,12 +26,7 @@ from Products.Formulator.Widget import Widget ...@@ -26,12 +26,7 @@ from Products.Formulator.Widget import Widget
from AccessControl import ClassSecurityInfo from AccessControl import ClassSecurityInfo
from zLOG import LOG from zLOG import LOG
class PatchedField(Field): def Field_generate_field_key(self, validation=0, key=None):
security = ClassSecurityInfo()
security.declareProtected('Access contents information',
'generate_field_key')
def generate_field_key(self, validation=0, key=None):
"""Generate the key Silva uses to render the field in the form. """Generate the key Silva uses to render the field in the form.
""" """
# Patched by JPS for ERP5 in order to # Patched by JPS for ERP5 in order to
...@@ -47,8 +42,7 @@ class PatchedField(Field): ...@@ -47,8 +42,7 @@ class PatchedField(Field):
else: else:
return '%s.%s:record' % (self.field_record, self.id) return '%s.%s:record' % (self.field_record, self.id)
security.declareProtected('View', 'render') def Field_render(self, value=None, REQUEST=None, key=None):
def render(self, value=None, REQUEST=None, key=None):
"""Render the field widget. """Render the field widget.
value -- the value the field should have (for instance value -- the value the field should have (for instance
from validation). from validation).
...@@ -60,8 +54,7 @@ class PatchedField(Field): ...@@ -60,8 +54,7 @@ class PatchedField(Field):
""" """
return self._render_helper(self.generate_field_key(key=key), value, REQUEST) return self._render_helper(self.generate_field_key(key=key), value, REQUEST)
security.declareProtected('View', 'render_sub_field') def Field_render_sub_field(self, id, value=None, REQUEST=None, key=None):
def render_sub_field(self, id, value=None, REQUEST=None, key=None):
"""Render a sub field, as part of complete rendering of widget in """Render a sub field, as part of complete rendering of widget in
a form. Works like render() but for sub field. a form. Works like render() but for sub field.
Added key parameter for ERP5 in order to be compatible with listbox/matrixbox Added key parameter for ERP5 in order to be compatible with listbox/matrixbox
...@@ -69,7 +62,7 @@ class PatchedField(Field): ...@@ -69,7 +62,7 @@ class PatchedField(Field):
return self.sub_form.get_field(id)._render_helper( return self.sub_form.get_field(id)._render_helper(
self.generate_subfield_key(id, key=key), value, REQUEST) self.generate_subfield_key(id, key=key), value, REQUEST)
def generate_subfield_key(self, id, validation=0, key=None): def Field_generate_subfield_key(self, id, validation=0, key=None):
"""Generate the key Silva uses to render a sub field. """Generate the key Silva uses to render a sub field.
Added key parameter for ERP5 Added key parameter for ERP5
Added key parameter for ERP5 in order to be compatible with listbox/matrixbox Added key parameter for ERP5 in order to be compatible with listbox/matrixbox
...@@ -79,17 +72,17 @@ class PatchedField(Field): ...@@ -79,17 +72,17 @@ class PatchedField(Field):
return 'subfield_%s_%s'%(key, id) return 'subfield_%s_%s'%(key, id)
return '%s.subfield_%s_%s:record' % (self.field_record, key, id) return '%s.subfield_%s_%s:record' % (self.field_record, key, id)
def validate_sub_field(self, id, REQUEST, key=None): def Field_validate_sub_field(self, id, REQUEST, key=None):
"""Validates a subfield (as part of field validation). """Validates a subfield (as part of field validation).
""" """
return self.sub_form.get_field(id)._validate_helper( return self.sub_form.get_field(id)._validate_helper(
self.generate_subfield_key(id, validation=1, key=key), REQUEST) self.generate_subfield_key(id, validation=1, key=key), REQUEST)
Field.generate_field_key = PatchedField.generate_field_key Field.generate_field_key = Field_generate_field_key
Field.render = PatchedField.render Field.render = Field_render
Field.render_sub_field = PatchedField.render_sub_field Field.render_sub_field = Field_render_sub_field
Field.generate_subfield_key = PatchedField.generate_subfield_key Field.generate_subfield_key = Field_generate_subfield_key
Field.validate_sub_field = PatchedField.validate_sub_field Field.validate_sub_field = Field_validate_sub_field
from Products.Formulator.Validator import SelectionValidator from Products.Formulator.Validator import SelectionValidator
from Products.Formulator.Validator import StringBaseValidator from Products.Formulator.Validator import StringBaseValidator
...@@ -564,14 +557,7 @@ MultiItemsWidget.render_items = MultiItemsWidget_render_items ...@@ -564,14 +557,7 @@ MultiItemsWidget.render_items = MultiItemsWidget_render_items
# JPS - Subfield handling with listbox requires extension # JPS - Subfield handling with listbox requires extension
from Products.Formulator.StandardFields import DateTimeField from Products.Formulator.StandardFields import DateTimeField
class PatchedDateTimeField(DateTimeField): def DateTimeField_get_default(self, key, value, REQUEST):
"""
Make sur we test if this REQUEST parameter has a form
attribute. In ERP5, we sometimes use the REQUEST to pass
subobjects to forms.
"""
def _get_default(self, key, value, REQUEST):
if value is not None: if value is not None:
return value return value
# if there is something in the request then return None # if there is something in the request then return None
...@@ -582,7 +568,7 @@ class PatchedDateTimeField(DateTimeField): ...@@ -582,7 +568,7 @@ class PatchedDateTimeField(DateTimeField):
else: else:
return self.get_value('default') return self.get_value('default')
DateTimeField._get_default = PatchedDateTimeField._get_default DateTimeField._get_default = DateTimeField_get_default
from Products.Formulator.Widget import DateTimeWidget from Products.Formulator.Widget import DateTimeWidget
......
...@@ -61,7 +61,7 @@ import FormulatorPatch ...@@ -61,7 +61,7 @@ import FormulatorPatch
import psyco import psyco
psyco.bind(ListBox.ListBoxWidget.render) psyco.bind(ListBox.ListBoxWidget.render)
psyco.bind(ListBox.ListBoxValidator.validate) psyco.bind(ListBox.ListBoxValidator.validate)
psyco.bind(Form.ERP5Field.get_value) #psyco.bind(Form.ERP5Field.get_value)
#psyco.bind(Form.ERP5Form.__call__) #psyco.bind(Form.ERP5Form.__call__)
#psyco.bind(Form.ERP5Form._exec) #psyco.bind(Form.ERP5Form._exec)
......
...@@ -24,9 +24,7 @@ from Products.CMFCore.FSZSQLMethod import FSZSQLMethod ...@@ -24,9 +24,7 @@ from Products.CMFCore.FSZSQLMethod import FSZSQLMethod
from Products.CMFCore.DirectoryView import expandpath from Products.CMFCore.DirectoryView import expandpath
from Products.ZSQLMethods.SQL import SQL from Products.ZSQLMethods.SQL import SQL
class PatchedFSZSQLMethod(FSZSQLMethod): def FSZSQLMethod_readFile(self, reparse):
def _readFile(self, reparse):
fp = expandpath(self._filepath) fp = expandpath(self._filepath)
file = open(fp, 'r') # not 'rb', as this is a text file! file = open(fp, 'r') # not 'rb', as this is a text file!
try: try:
...@@ -39,7 +37,7 @@ class PatchedFSZSQLMethod(FSZSQLMethod): ...@@ -39,7 +37,7 @@ class PatchedFSZSQLMethod(FSZSQLMethod):
self.PUT(RESPONSE,None) self.PUT(RESPONSE,None)
def _createZODBClone(self): def FSZSQLMethod_createZODBClone(self):
"""Create a ZODB (editable) equivalent of this object.""" """Create a ZODB (editable) equivalent of this object."""
# I guess it's bad to 'reach inside' ourselves like this, # I guess it's bad to 'reach inside' ourselves like this,
# but Z SQL Methods don't have accessor methdods ;-) # but Z SQL Methods don't have accessor methdods ;-)
...@@ -55,8 +53,8 @@ class PatchedFSZSQLMethod(FSZSQLMethod): ...@@ -55,8 +53,8 @@ class PatchedFSZSQLMethod(FSZSQLMethod):
self.class_file_) self.class_file_)
return s return s
FSZSQLMethod._readFile = PatchedFSZSQLMethod._readFile FSZSQLMethod._readFile = FSZSQLMethod_readFile
FSZSQLMethod._createZODBClone = PatchedFSZSQLMethod._createZODBClone FSZSQLMethod._createZODBClone = FSZSQLMethod_createZODBClone
from Products.CMFCore import ActionInformation from Products.CMFCore import ActionInformation
from AccessControl import ClassSecurityInfo from AccessControl import ClassSecurityInfo
...@@ -188,9 +186,7 @@ ActionInformation.ActionInformation = PatchedActionInformation ...@@ -188,9 +186,7 @@ ActionInformation.ActionInformation = PatchedActionInformation
from Products.CMFCore.ActionProviderBase import ActionProviderBase from Products.CMFCore.ActionProviderBase import ActionProviderBase
from Products.CMFCore.ActionInformation import ActionInformation from Products.CMFCore.ActionInformation import ActionInformation
class PatchedActionProviderBase(ActionProviderBase): def ActionProviderBase_manage_editActionsForm( self, REQUEST, manage_tabs_message=None ):
def manage_editActionsForm( self, REQUEST, manage_tabs_message=None ):
""" Show the 'Actions' management tab. """ Show the 'Actions' management tab.
""" """
...@@ -227,7 +223,7 @@ class PatchedActionProviderBase(ActionProviderBase): ...@@ -227,7 +223,7 @@ class PatchedActionProviderBase(ActionProviderBase):
) )
def addAction( self def ActionProviderBase_addAction( self
, id , id
, name , name
, action , action
...@@ -272,7 +268,7 @@ class PatchedActionProviderBase(ActionProviderBase): ...@@ -272,7 +268,7 @@ class PatchedActionProviderBase(ActionProviderBase):
REQUEST, manage_tabs_message='Added.') REQUEST, manage_tabs_message='Added.')
def _extractAction( self, properties, index ): def ActionProviderBase_extractAction( self, properties, index ):
""" Extract an ActionInformation from the funky form properties. """ Extract an ActionInformation from the funky form properties.
""" """
...@@ -327,7 +323,7 @@ class PatchedActionProviderBase(ActionProviderBase): ...@@ -327,7 +323,7 @@ class PatchedActionProviderBase(ActionProviderBase):
, optional=optional , optional=optional
) )
ActionProviderBase.manage_editActionsForm = PatchedActionProviderBase.manage_editActionsForm ActionProviderBase.manage_editActionsForm = ActionProviderBase_manage_editActionsForm
ActionProviderBase.addAction = PatchedActionProviderBase.addAction ActionProviderBase.addAction = ActionProviderBase_addAction
ActionProviderBase._extractAction = PatchedActionProviderBase._extractAction ActionProviderBase._extractAction = ActionProviderBase_extractAction
This diff is collapsed.
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