Commit c9004080 authored by Yoshinori Okuji's avatar Yoshinori Okuji

Use a request object instead of a volatile variable.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@5481 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 6ccdb59c
No related merge requests found
......@@ -58,6 +58,7 @@ def get_value(self, id, **kw):
tales_expr = self.tales.get(id, "")
if tales_expr:
REQUEST = get_request
form = self.aq_parent
object = getattr(form, 'aq_parent', None)
if object:
......@@ -69,7 +70,7 @@ def get_value(self, id, **kw):
container = None
kw['field'] = self
kw['form'] = form
kw['request'] = get_request()
kw['request'] = REQUEST
kw['here'] = object
kw['container'] = container
try :
......@@ -77,7 +78,7 @@ def get_value(self, id, **kw):
except AttributeError :
LOG('ERP5Form', 0,
'portal_preferences not put in TALES context (not installed?)')
extra_context = getattr(self, '_v_extra_context', None)
extra_context = REQUEST.get('erp5_extra_context', None)
if extra_context:
kw.update(extra_context)
# This allows to pass some pointer to the local object
......
......@@ -97,34 +97,25 @@ class ProxyWidget(Widget.Widget):
form = field.aq_parent
proxy_form = getattr(form, field.get_value('form_id'))
proxy_field = getattr(proxy_form, field.get_value('field_id'))
extra_context = field.get_value('extra_context')
if not hasattr(proxy_field, '_v_extra_context'):
proxy_field._v_extra_context = {}
for k, v in extra_context:
proxy_field._v_extra_context[k] = v
try:
return proxy_field.widget.render(proxy_field, key, value, REQUEST)
finally:
if hasattr(proxy_field, '_v_extra_context'):
del proxy_field._v_extra_context
extra_context = REQUEST.get('erp5_extra_context', {})
for k, v in field.get_value('extra_context'):
extra_context[k] = v
REQUEST['erp5_extra_context'] = extra_context
return proxy_field.widget.render(proxy_field, key, value, REQUEST)
def render_view(self, field, value):
"""
"""
Display proxy field
"""
form = field.aq_parent
proxy_form = getattr(form, field.get_value('form_id'))
proxy_field = getattr(proxy_form, field.get_value('field_id'))
extra_context = field.get_value('extra_context')
if not hasattr(proxy_field, '_v_extra_context'):
proxy_field._v_extra_context = {}
for k, v in extra_context:
proxy_field._v_extra_context[k] = v
try:
return proxy_field.widget.render_view(proxy_field, key, value)
finally:
if hasattr(proxy_field, '_v_extra_context'):
del proxy_field._v_extra_context
REQUEST = get_request()
extra_context = REQUEST.get('erp5_extra_context', {})
for k, v in field.get_value('extra_context'):
extra_context[k] = v
REQUEST['erp5_extra_context'] = extra_context
return proxy_field.widget.render_view(proxy_field, key, value)
class ProxyValidator(Validator.Validator):
......
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