Commit 13b4d766 authored by Kazuhiko Shiozaki's avatar Kazuhiko Shiozaki

set REQUEST['original_context'] in FormBox if context_method_id is used.

so that we can reach the original context where FormBox is used.
also clean up modified REQUEST after rendering the target form.
parent 70db1e05
...@@ -112,13 +112,16 @@ class FormBoxWidget(Widget.Widget): ...@@ -112,13 +112,16 @@ class FormBoxWidget(Widget.Widget):
here = REQUEST['here'] here = REQUEST['here']
context_method_id = field.get_value('context_method_id') context_method_id = field.get_value('context_method_id')
if context_method_id: if context_method_id:
original_here = here REQUEST['original_context'] = original_here = here
REQUEST['here'] = here = getattr(here, context_method_id)() REQUEST['here'] = here = getattr(here, context_method_id)()
# If 'cell' is not defined, we define 'cell' just same as 'here', so # If 'cell' is not defined, we define 'cell' just same as 'here', so
# that we can use the same formbox for both ListBox and non-ListBox # that we can use the same formbox for both ListBox and non-ListBox
# using 'cell' parameter. # using 'cell' parameter.
if not REQUEST.has_key('cell'): if not REQUEST.has_key('cell'):
set_cell = True
REQUEST.set('cell', here) REQUEST.set('cell', here)
else:
set_sell = False
try: try:
form = getattr(here, target_id) form = getattr(here, target_id)
except AttributeError: except AttributeError:
...@@ -130,6 +133,9 @@ class FormBoxWidget(Widget.Widget): ...@@ -130,6 +133,9 @@ class FormBoxWidget(Widget.Widget):
finally: finally:
if context_method_id: if context_method_id:
REQUEST['here'] = original_here REQUEST['here'] = original_here
del REQUEST.other['original_context']
if set_cell:
del REQUEST.other['cell']
return result return result
class FormBoxEditor: class FormBoxEditor:
......
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