def getFieldValue(self, field, id, **kw): """ Return a callable expression and cacheable boolean flag """ # Some field types have their own get_value implementation, # then we must use it always. This check must be done at first. template_field = self.getRecursiveTemplateField() # Old ListBox instance might have default attribute. so we need to check it. if checkOriginalGetValue(template_field, id): return _USE_ORIGINAL_GET_VALUE_MARKER, True try: tales_expr = self.get_tales_expression(id) except ValueError: return None, False if tales_expr: tales_expr = copyMethod(tales_expr) return TALESValue(tales_expr), isCacheable(tales_expr) # FIXME: backwards compat hack to make sure overrides dict exists if not hasattr(self, 'overrides'): self.overrides = {} override = self.overrides.get(id, "") if override: override = copyMethod(override) return OverrideValue(override), isCacheable(override) # Get a normal value. try: value = self.get_recursive_orig_value(id) except KeyError: # For ListBox and other exceptional fields. return self._get_value(id, **kw), False field_id = field.id value = copyMethod(value) cacheable = isCacheable(value) if id == 'default' and (field_id.startswith('my_') or field_id.startswith('listbox_')): # XXX far from object-oriented programming if template_field.meta_type == 'CheckBoxField': return DefaultCheckBoxValue(field_id, value), cacheable return DefaultValue(field_id, value), cacheable # For the 'editable' value, we try to get a default value if id == 'editable': return EditableValue(value), cacheable # Return default value in callable mode if callable(value): return StaticValue(value), cacheable # Return default value in non callable mode return_value = StaticValue(value)(field, id, **kw) return return_value, isCacheable(return_value)
def getFieldValue(self, field, id, **kw): """ Return a callable expression and cacheable boolean flag """ # Some field types have their own get_value implementation, # then we must use it always. This check must be done at first. template_field = self.getRecursiveTemplateField() # Old ListBox instance might have default attribute. so we need to check it. if checkOriginalGetValue(template_field, id): return _USE_ORIGINAL_GET_VALUE_MARKER, True try: tales_expr = self.get_tales_expression(id) except ValueError: return None, False if tales_expr: tales_expr = copyMethod(tales_expr) return TALESValue(tales_expr), isCacheable(tales_expr) # FIXME: backwards compat hack to make sure overrides dict exists if not hasattr(self, 'overrides'): self.overrides = {} override = self.overrides.get(id, "") if override: override = copyMethod(override) return OverrideValue(override), isCacheable(override) # Get a normal value. try: value = self.get_recursive_orig_value(id) except KeyError: # For ListBox and other exceptional fields. return self._get_value(id, **kw), False field_id = field.id value = copyMethod(value) cacheable = isCacheable(value) if id == 'default' and (field_id.startswith('my_') or field_id.startswith('listbox_')): # XXX far from object-oriented programming if template_field.meta_type == 'CheckBoxField': return DefaultCheckBoxValue(field_id, value), cacheable return DefaultValue(field_id, value), cacheable # For the 'editable' value, we try to get a default value if id == 'editable': return EditableValue(value), cacheable # Return default value in callable mode if callable(value): return StaticValue(value), cacheable # Return default value in non callable mode return_value = StaticValue(value)(field, id, **kw) return return_value, isCacheable(return_value)