[enh] display CWConstraint type in its repr
authorLaurent Peuch <cortex@worlddomination.be>
Thu, 16 May 2019 01:23:51 +0200
changeset 12606 ea15ac05c447
parent 12604 c755b73640ea
child 12607 3bf9002de48e
[enh] display CWConstraint type in its repr This will change CWConstraint repr from something like: <Entity CWConstraint 314282 [] at 140127700141904> To: <Entity CWConstraint 314282 of type UniqueConstraint [] at 140127700141904> To help improve debugging UX a little bit.
cubicweb/entities/schemaobjs.py
--- a/cubicweb/entities/schemaobjs.py	Wed May 15 14:23:19 2019 +0200
+++ b/cubicweb/entities/schemaobjs.py	Thu May 16 01:23:51 2019 +0200
@@ -141,6 +141,10 @@
     __regid__ = 'CWConstraint'
     fetch_attrs, cw_fetch_order = fetch_config(['value'])
 
+    def __repr__(self):
+        return '<Entity %s %s of type %s %s at %s>' % (
+            self.e_schema, self.eid, self.type, list(self.cw_attr_cache), id(self))
+
     def dc_title(self):
         return '%s(%s)' % (self.cstrtype[0].name, self.value or u'')