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):
......
...@@ -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)
......
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