entities/adapters.py
changeset 9990 c84ad981fc4a
parent 9918 228c3571e222
child 10262 5c2a4a0a8dbd
child 10280 2cdab5e33542
equal deleted inserted replaced
9974:b240b33c7125 9990:c84ad981fc4a
   365         for rtype in rtypes:
   365         for rtype in rtypes:
   366             rtypes_msg[rtype] = _('%s is part of violated unicity constraint') % rtype
   366             rtypes_msg[rtype] = _('%s is part of violated unicity constraint') % rtype
   367         globalmsg = _('some relations violate a unicity constraint')
   367         globalmsg = _('some relations violate a unicity constraint')
   368         rtypes_msg['unicity constraint'] = globalmsg
   368         rtypes_msg['unicity constraint'] = globalmsg
   369         raise ValidationError(self.entity.eid, rtypes_msg)
   369         raise ValidationError(self.entity.eid, rtypes_msg)
   370 
       
   371 # deprecated ###################################################################
       
   372 
       
   373 
       
   374 class adapter_deprecated(view.auto_unwrap_bw_compat):
       
   375     """metaclass to print a warning on instantiation of a deprecated class"""
       
   376 
       
   377     def __call__(cls, *args, **kwargs):
       
   378         msg = getattr(cls, "__deprecation_warning__",
       
   379                       "%(cls)s is deprecated") % {'cls': cls.__name__}
       
   380         warn(msg, DeprecationWarning, stacklevel=2)
       
   381         return type.__call__(cls, *args, **kwargs)