equal
deleted
inserted
replaced
18 """some basic entity adapter implementations, for interfaces used in the |
18 """some basic entity adapter implementations, for interfaces used in the |
19 framework itself. |
19 framework itself. |
20 """ |
20 """ |
21 |
21 |
22 __docformat__ = "restructuredtext en" |
22 __docformat__ = "restructuredtext en" |
|
23 _ = unicode |
23 |
24 |
24 from itertools import chain |
25 from itertools import chain |
25 from warnings import warn |
26 from warnings import warn |
26 |
27 |
27 from logilab.mtconverter import TransformError |
28 from logilab.mtconverter import TransformError |
357 |
358 |
358 class IUserFriendlyUniqueTogether(IUserFriendlyError): |
359 class IUserFriendlyUniqueTogether(IUserFriendlyError): |
359 __select__ = match_exception(UniqueTogetherError) |
360 __select__ = match_exception(UniqueTogetherError) |
360 |
361 |
361 def raise_user_exception(self): |
362 def raise_user_exception(self): |
362 _ = self._cw._ |
|
363 rtypes = self.exc.rtypes |
363 rtypes = self.exc.rtypes |
364 rtypes_msg = {} |
364 errors = {} |
|
365 msgargs = {} |
|
366 i18nvalues = [] |
365 for rtype in rtypes: |
367 for rtype in rtypes: |
366 rtypes_msg[rtype] = _('%s is part of violated unicity constraint') % rtype |
368 errors[rtype] = _('%(KEY-rtype)s is part of violated unicity constraint') |
367 globalmsg = _('some relations violate a unicity constraint') |
369 msgargs[rtype + '-rtype'] = rtype |
368 rtypes_msg['unicity constraint'] = globalmsg |
370 i18nvalues.append(rtype + '-rtype') |
369 raise ValidationError(self.entity.eid, rtypes_msg) |
371 errors[''] = _('some relations violate a unicity constraint') |
|
372 raise ValidationError(self.entity.eid, errors, msgargs=msgargs, i18nvalues=i18nvalues) |