• Julien Muchembled's avatar
    ERP5Form: when editing a FormBox, do not compute the context twice (and wrongly) · ab388d7f
    Julien Muchembled authored
    This first reverts the following 2 commits:
      566c0c5f
      3a08c758
    
    to at least fix the issue that the context method takes 2 arguments that aren't
    available from FormBoxEditor.edit() without slowing things even more.
    
    About deferred style, widget editor objects can be ignored for the moment. If
    we ever need to restore fully functional objects, the regression in commit
      a5a2f1cd
    could be solved with the following patch:
    
    --- a/product/ERP5Form/FormBox.py
    +++ b/product/ERP5Form/FormBox.py
    @@ -131,22 +131,32 @@ def render(self, field, key, value, REQUEST, render_prefix=None):
     class FormBoxEditor:
       """An editor returned from FormBox validation able to `edit` document."""
     
    +  path = None
    +
       def __init__(self, result, context):
         """Initialize with all necessary information for editing.
     
         Keep a reference to the correct context and don't expect the caller to provide it
         during the edit phase because they don't have access to the widget anymore.
         """
         self.attr_dict, self.editor_list = result
    +    self.context = context
         self.edit = lambda _: self._edit(context)
     
       def __getstate__(self):
    -    pass
    +    return (self.attr_dict, self.editor_list,
    +            self.path or self.context.getPhysicalPath())
    +
    +  def __setstate__(self, state):
    +    self.attr_dict, self.editor_list, self.path = state
     
       def __call__(self, REQUEST):
         # Called by Base_edit in case of FormValidationError
         pass
     
    +  def edit(self, context):
    +    return self._edit(context.unrestrictedTraverse(self.path))
    +
       def _edit(self, context):
         """Edit inside correct context."""
         context.edit(**self.attr_dict)
    
    This commit also removes the unused view() method on editors.
    
    /reviewed-on !622
    ab388d7f
MultiRelationField.py 28.4 KB