Commit d2153773 authored by Jean-Paul Smets's avatar Jean-Paul Smets

Only use getObject if needed.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@20637 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 02d029b2
...@@ -1925,7 +1925,7 @@ class ListBoxRendererLine: ...@@ -1925,7 +1925,7 @@ class ListBoxRendererLine:
processed_value = original_value processed_value = original_value
else: else:
# This is an usual line. # This is an usual line.
obj = self.getObject() obj = None # Only evaluate if needed
brain = self.getBrain() brain = self.getBrain()
# Use a widget, if any. # Use a widget, if any.
...@@ -1934,37 +1934,40 @@ class ListBoxRendererLine: ...@@ -1934,37 +1934,40 @@ class ListBoxRendererLine:
if editable_field is not None: if editable_field is not None:
tales = editable_field.tales.get('default', '') tales = editable_field.tales.get('default', '')
if tales: if tales:
if obj is None: obj = self.getObject()
original_value = editable_field.__of__(obj).get_value('default', original_value = editable_field.__of__(obj).get_value('default',
cell=brain) cell=brain)
processed_value = original_value processed_value = original_value
# If a tales expression is not defined, get a skin, an accessor or a property. # If a tales expression is not defined, get a skin, an accessor or a property.
if not tales: if not tales:
if brain is not obj and getattr(aq_self(brain), alias, None) is not None: if (obj is None or brain is not obj) and getattr(aq_self(brain), alias, None) is not None:
original_value = getattr(brain, alias) original_value = getattr(brain, alias)
processed_value = original_value processed_value = original_value
elif obj is not None: else:
try: obj = self.getObject()
# Get the trailing part. if obj is not None:
try:
property_id = sql[sql.rindex('.') + 1:]
except ValueError:
property_id = sql
try: try:
original_value = obj.getProperty(property_id, _marker) # Get the trailing part.
if original_value is _marker: try:
raise AttributeError, property_id property_id = sql[sql.rindex('.') + 1:]
processed_value = original_value except ValueError:
except AttributeError: property_id = sql
original_value = getattr(obj, property_id, None)
processed_value = original_value try:
except (AttributeError, KeyError, Unauthorized): original_value = obj.getProperty(property_id, _marker)
if original_value is _marker:
raise AttributeError, property_id
processed_value = original_value
except AttributeError:
original_value = getattr(obj, property_id, None)
processed_value = original_value
except (AttributeError, KeyError, Unauthorized):
original_value = None
processed_value = 'Could not evaluate %s' % property_id
else:
original_value = None original_value = None
processed_value = 'Could not evaluate %s' % property_id processed_value = 'Object does not exist'
else:
original_value = None
processed_value = 'Object does not exist'
# If the value is callable, evaluate it. # If the value is callable, evaluate it.
if callable(original_value): if callable(original_value):
......
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