server/schemahooks.py
branchreldefsecurity
changeset 3889 8902b8745918
parent 3877 7ca53fc72a0a
parent 3881 a192bc3c13b7
equal deleted inserted replaced
3877:7ca53fc72a0a 3889:8902b8745918
   904 def check_valid_changes(session, entity, ro_attrs=('name', 'final')):
   904 def check_valid_changes(session, entity, ro_attrs=('name', 'final')):
   905     errors = {}
   905     errors = {}
   906     # don't use getattr(entity, attr), we would get the modified value if any
   906     # don't use getattr(entity, attr), we would get the modified value if any
   907     for attr in ro_attrs:
   907     for attr in ro_attrs:
   908         if attr in entity.edited_attributes:
   908         if attr in entity.edited_attributes:
   909             orival, newval = entity_oldnewvalue(entity, attr)
   909             origval, newval = entity_oldnewvalue(entity, attr)
   910             if newval != origval:
   910             if newval != origval:
   911                 errors[attr] = session._("can't change the %s attribute") % \
   911                 errors[attr] = session._("can't change the %s attribute") % \
   912                                display_name(session, attr)
   912                                display_name(session, attr)
   913     if errors:
   913     if errors:
   914         raise ValidationError(entity.eid, errors)
   914         raise ValidationError(entity.eid, errors)