server/schemahooks.py
branchstable
changeset 3881 a192bc3c13b7
parent 3870 a6b029aa0f44
child 3889 8902b8745918
child 4129 887e3edc30c5
equal deleted inserted replaced
3878:3af225f0faa0 3881:a192bc3c13b7
   961 def check_valid_changes(session, entity, ro_attrs=('name', 'final')):
   961 def check_valid_changes(session, entity, ro_attrs=('name', 'final')):
   962     errors = {}
   962     errors = {}
   963     # don't use getattr(entity, attr), we would get the modified value if any
   963     # don't use getattr(entity, attr), we would get the modified value if any
   964     for attr in ro_attrs:
   964     for attr in ro_attrs:
   965         if attr in entity.edited_attributes:
   965         if attr in entity.edited_attributes:
   966             orival, newval = entity_oldnewvalue(entity, attr)
   966             origval, newval = entity_oldnewvalue(entity, attr)
   967             if newval != origval:
   967             if newval != origval:
   968                 errors[attr] = session._("can't change the %s attribute") % \
   968                 errors[attr] = session._("can't change the %s attribute") % \
   969                                display_name(session, attr)
   969                                display_name(session, attr)
   970     if errors:
   970     if errors:
   971         raise ValidationError(entity.eid, errors)
   971         raise ValidationError(entity.eid, errors)