Commit 50786ab8 authored by Yusei Tahara's avatar Yusei Tahara

Moved edit function from Base_edit script and added as ListBoxEditor class.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@15536 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 13e8519c
...@@ -2997,10 +2997,40 @@ class ListBoxValidator(Validator.Validator): ...@@ -2997,10 +2997,40 @@ class ListBoxValidator(Validator.Validator):
LOG("ListBox FormValidationError",0,str(error_result)) LOG("ListBox FormValidationError",0,str(error_result))
LOG("ListBox FormValidationError",0,str(errors)) LOG("ListBox FormValidationError",0,str(errors))
raise FormValidationError(errors, error_result) raise FormValidationError(errors, error_result)
return result
return ListBoxEditor(field, result)
ListBoxValidatorInstance = ListBoxValidator() ListBoxValidatorInstance = ListBoxValidator()
class ListBoxEditor:
"""
A class holding all values required to update objects
"""
def __init__(self, field, update_dict):
self.field = field
self.update_dict = update_dict
def view(self):
return self.__dict__
def __call__(self, REQUEST):
pass
def edit(self, context):
if self.update_dict is not None:
gv = {}
if self.field.has_value('global_attributes'):
hidden_attributes = map(lambda x:x[0], self.field.get_value('global_attributes'))
for k in hidden_attributes:
gv[k] = getattr(request, k, None)
for url, v in self.update_dict.items():
v.update(gv)
self.field.restrictedTraverse(url).edit(**v)
allow_class(ListBoxEditor)
class ListBox(ZMIField): class ListBox(ZMIField):
meta_type = "ListBox" meta_type = "ListBox"
......
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