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