Commit 0b16904e authored by Sebastien Robin's avatar Sebastien Robin

access to cell in tales expression


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@1047 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent f8e5e681
...@@ -1003,33 +1003,47 @@ onChange="submitAction(this.form,'%s/portal_selections/setReportRoot')"> ...@@ -1003,33 +1003,47 @@ onChange="submitAction(this.form,'%s/portal_selections/setReportRoot')">
else: else:
property_id = alias property_id = alias
# attribute_value = getattr(o, cname_id) # FUTURE WAY OF DOING TGW Brains # attribute_value = getattr(o, cname_id) # FUTURE WAY OF DOING TGW Brains
if hasattr(aq_self(o),alias): # Block acquisition to reduce risks my_field = None
# First take the indexed value tales_expr = None
attribute_value = getattr(o,alias) # We may need acquisition in case of method call if form.has_field('%s_%s' % (field.id, alias) ):
my_field_id = '%s_%s' % (field.id, alias)
my_field = form.get_field(my_field_id)
tales_expr = my_field.tales.get('default', "")
if tales_expr:
#
real_o = o
if hasattr(o,'getObject'): # we have a line of sql result
real_o = o.getObject()
field_kw = {'cell':real_o}
attribute_value = my_field.__of__(real_o).get_value('default',**field_kw)
else: else:
# MUST IMPROVE FOR PERFORMANCE REASON if hasattr(aq_self(o),alias): # Block acquisition to reduce risks
# attribute_value = 'Does not exist' # First take the indexed value
if real_o is None: attribute_value = getattr(o,alias) # We may need acquisition in case of method call
try: else:
real_o = o.getObject() # MUST IMPROVE FOR PERFORMANCE REASON
except: # attribute_value = 'Does not exist'
pass if real_o is None:
if real_o is not None:
try:
try: try:
attribute_value = getattr(real_o,property_id, None) real_o = o.getObject()
#LOG('Look up attribute %s' % cname_id,0,str(attribute_value))
if not callable(attribute_value):
#LOG('Look up accessor %s' % cname_id,0,'')
attribute_value = real_o.getProperty(property_id)
#LOG('Look up accessor %s' % cname_id,0,str(attribute_value))
except: except:
attribute_value = getattr(real_o,property_id) pass
#LOG('Fallback to attribute %s' % cname_id,0,str(attribute_value)) if real_o is not None:
except: try:
attribute_value = 'Can not evaluate attribute: %s' % sql try:
else: attribute_value = getattr(real_o,property_id, None)
attribute_value = 'Object does not exist' #LOG('Look up attribute %s' % cname_id,0,str(attribute_value))
if not callable(attribute_value):
#LOG('Look up accessor %s' % cname_id,0,'')
attribute_value = real_o.getProperty(property_id)
#LOG('Look up accessor %s' % cname_id,0,str(attribute_value))
except:
attribute_value = getattr(real_o,property_id)
#LOG('Fallback to attribute %s' % cname_id,0,str(attribute_value))
except:
attribute_value = 'Can not evaluate attribute: %s' % sql
else:
attribute_value = 'Object does not exist'
if callable(attribute_value): if callable(attribute_value):
try: try:
attribute_value = attribute_value() attribute_value = attribute_value()
...@@ -1047,8 +1061,6 @@ onChange="submitAction(this.form,'%s/portal_selections/setReportRoot')"> ...@@ -1047,8 +1061,6 @@ onChange="submitAction(this.form,'%s/portal_selections/setReportRoot')">
else: else:
td_align = "left" td_align = "left"
if sql in editable_column_ids and form.has_field('%s_%s' % (field.id, alias) ): if sql in editable_column_ids and form.has_field('%s_%s' % (field.id, alias) ):
my_field_id = '%s_%s' % (field.id, alias)
my_field = form.get_field(my_field_id)
key = my_field.id + '_%s' % o.uid key = my_field.id + '_%s' % o.uid
if field_errors.has_key(key): if field_errors.has_key(key):
error_css = 'Error' error_css = 'Error'
......
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