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