# HG changeset patch # User sylvain.thenault@logilab.fr # Date 1241595986 -7200 # Node ID 9fb5b4741a08ab721f1416718dacb7edb34f59bf # Parent b5b323f8a05b47cbfd91507fe92022753c1ad098 use values cached on the entity if any diff -r b5b323f8a05b -r 9fb5b4741a08 web/form.py --- a/web/form.py Tue May 05 19:35:55 2009 +0200 +++ b/web/form.py Wed May 06 09:46:26 2009 +0200 @@ -520,9 +520,7 @@ return INTERNAL_FIELD_VALUE if attr == '__type': return entity.id - if field.role == 'object': - attr = 'reverse_' + attr - elif entity.e_schema.subject_relation(attr).is_final(): + if self.schema.rschema(attr).is_final(): attrtype = entity.e_schema.destination(attr) if attrtype == 'Password': return entity.has_eid() and INTERNAL_FIELD_VALUE or '' @@ -533,14 +531,14 @@ # XXX value should reflect if some file is already attached return True return False - if entity.has_eid(): + if entity.has_eid() or attr in entity: value = getattr(entity, attr) else: value = self._form_field_default_value(field, load_bytes) return value # non final relation field - if entity.has_eid(): - value = [ent.eid for ent in getattr(entity, attr)] + if entity.has_eid() or entity.relation_cached(attr, field.role): + value = [r[0] for r in entity.related(attr, field.role)] else: value = self._form_field_default_value(field, load_bytes) return value