Commit 6e895dcf authored by Kevin Deldycke's avatar Kevin Deldycke

Make "cell" attribute working in tales expression of editable widget within listbox

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@8468 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 1c10097a
...@@ -59,7 +59,7 @@ def get_value(self, id, **kw): ...@@ -59,7 +59,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() REQUEST = get_request()
form = self.aq_parent form = self.aq_parent # XXX (JPS) form for default is wrong apparently in listbox - double check
object = getattr(form, 'aq_parent', None) object = getattr(form, 'aq_parent', None)
if object: if object:
# NEEDS TO BE CHECKED # NEEDS TO BE CHECKED
...@@ -90,6 +90,9 @@ def get_value(self, id, **kw): ...@@ -90,6 +90,9 @@ def get_value(self, id, **kw):
kw['cell'] = getattr(kw['REQUEST'],'cell') kw['cell'] = getattr(kw['REQUEST'],'cell')
else: else:
kw['cell'] = kw['REQUEST'] kw['cell'] = kw['REQUEST']
elif not kw.get('cell'):
if getattr(REQUEST,'cell',None) is not None:
kw['cell'] = getattr(REQUEST,'cell')
try: try:
value = tales_expr.__of__(self)(**kw) value = tales_expr.__of__(self)(**kw)
except (ConflictError, RuntimeError): except (ConflictError, RuntimeError):
...@@ -343,7 +346,7 @@ class ERP5Form(ZMIForm, ZopePageTemplate): ...@@ -343,7 +346,7 @@ class ERP5Form(ZMIForm, ZopePageTemplate):
# Special Settings # Special Settings
settings_form = create_settings_form() settings_form = create_settings_form()
def __init__(self, id, title, unicode_mode=0, encoding='UTF-8', def __init__(self, id, title, unicode_mode=0, encoding='UTF-8',
stored_encoding='UTF-8'): stored_encoding='UTF-8'):
"""Initialize form. """Initialize form.
id -- id of form id -- id of form
...@@ -372,7 +375,7 @@ class ERP5Form(ZMIForm, ZopePageTemplate): ...@@ -372,7 +375,7 @@ class ERP5Form(ZMIForm, ZopePageTemplate):
extra_context['form'] = self extra_context['form'] = self
extra_context['container'] = container ## PROBLEM NOT TAKEN INTO ACCOUNT extra_context['container'] = container ## PROBLEM NOT TAKEN INTO ACCOUNT
extra_context['here'] = object extra_context['here'] = object
# We initialize here an index which is used to generate # We initialize here an index which is used to generate
# different method ids for every field # different method ids for every field
request = extra_context['request'] request = extra_context['request']
# XXX We must not use a counter, but a ID for each field # XXX We must not use a counter, but a ID for each field
......
...@@ -1898,14 +1898,29 @@ class ListBoxHTMLRendererLine(ListBoxRendererLine): ...@@ -1898,14 +1898,29 @@ class ListBoxHTMLRendererLine(ListBoxRendererLine):
# XXX this is a horrible hack. # XXX this is a horrible hack.
if editable_field.meta_type in ('DateTimeField', 'ProxyField', ): if editable_field.meta_type in ('DateTimeField', 'ProxyField', ):
# XXX Some fields prefer None to ''. # XXX Some fields prefer None to ''.
cell_html = editable_field.render(value = original_value, cell_html = editable_field.render( \
REQUEST = brain.asContext(REQUEST = self.renderer.request, form = self.renderer.request.form), value = original_value
key = key) , REQUEST = brain.asContext( \
REQUEST = self.renderer.request
, form = self.renderer.request.form
)
, key = key
)
else: else:
# We use REQUEST which is not so good here. # We use REQUEST which is not so good here.
# This prevents from using standard display process. # This prevents from using standard display process.
# XXX what does the above comment mean exactly? why don't we fix Formulator? # XXX what does the above comment mean exactly? why don't we fix Formulator?
cell_html = editable_field.render(value = display_value, REQUEST = brain, key = key) # XXX (JPS) - render_view does not get REQUEST - this breaks so many possibilities
# cell_html = editable_field.render(value = original_value,
# REQUEST = brain.asContext(cell = self.getObject()
# ),
# key = key)
REQUEST = get_request() # Dirtymax hack by JPS - render_view API update required
REQUEST.cell = self.getObject()
cell_html = editable_field.render( value = display_value
, REQUEST = brain
, key = key
)
if isinstance(cell_html, str): if isinstance(cell_html, str):
cell_html = unicode(cell_html, encoding) cell_html = unicode(cell_html, encoding)
...@@ -2864,8 +2879,8 @@ class ListBox(ZMIField): ...@@ -2864,8 +2879,8 @@ class ListBox(ZMIField):
def get_value(self, id, **kw): def get_value(self, id, **kw):
if (id == 'default'): if (id == 'default'):
if (kw.get('render_format') in ('list', )): if (kw.get('render_format') in ('list', )):
return self.widget.render(self, self.generate_field_key(), None, return self.widget.render(self, self.generate_field_key(), None,
kw.get('REQUEST'), kw.get('REQUEST'),
render_format=kw.get('render_format')) render_format=kw.get('render_format'))
else: else:
return None return None
......
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