[CalendarServer-changes] [10211] CalendarServer/branches/users/glyph/queue-locking-and-timing

source_changes at macosforge.org source_changes at macosforge.org
Fri Jan 4 16:38:19 PST 2013


Revision: 10211
          http://trac.calendarserver.org//changeset/10211
Author:   glyph at apple.com
Date:     2013-01-04 16:38:19 -0800 (Fri, 04 Jan 2013)
Log Message:
-----------
Nicer repr for debugging.

Modified Paths:
--------------
    CalendarServer/branches/users/glyph/queue-locking-and-timing/twext/enterprise/dal/record.py
    CalendarServer/branches/users/glyph/queue-locking-and-timing/twext/enterprise/dal/test/test_record.py

Property Changed:
----------------
    CalendarServer/branches/users/glyph/queue-locking-and-timing/

Modified: CalendarServer/branches/users/glyph/queue-locking-and-timing/twext/enterprise/dal/record.py
===================================================================
--- CalendarServer/branches/users/glyph/queue-locking-and-timing/twext/enterprise/dal/record.py	2013-01-05 00:38:18 UTC (rev 10210)
+++ CalendarServer/branches/users/glyph/queue-locking-and-timing/twext/enterprise/dal/record.py	2013-01-05 00:38:19 UTC (rev 10211)
@@ -143,6 +143,15 @@
         return super(Record, self).__setattr__(name, value)
 
 
+    def __repr__(self):
+        r = "<{0} record from table {1} ".format(self.__class__.__name__,
+                                                 self.table.model.name)
+        for k in sorted(self.__attrmap__.keys()):
+            r += "{0}={1}".format(k, repr(getattr(self, k)))
+        r += ">"
+        return r
+
+
     @staticmethod
     def namingConvention(columnName):
         """

Modified: CalendarServer/branches/users/glyph/queue-locking-and-timing/twext/enterprise/dal/test/test_record.py
===================================================================
--- CalendarServer/branches/users/glyph/queue-locking-and-timing/twext/enterprise/dal/test/test_record.py	2013-01-05 00:38:18 UTC (rev 10210)
+++ CalendarServer/branches/users/glyph/queue-locking-and-timing/twext/enterprise/dal/test/test_record.py	2013-01-05 00:38:19 UTC (rev 10211)
@@ -238,7 +238,18 @@
             sorted(data)
         )
 
+    @inlineCallbacks
+    def test_repr(self):
+        """
+        The C{repr} of a L{Record} presents all its values.
+        """
+        txn = self.pool.connection()
+        yield txn.execSQL("insert into ALPHA values (:1, :2)", [789, u'nine'])
+        rec = list((yield TestRecord.all(txn)))[0]
+        self.assertIn("789", repr(rec))
+        self.assertIn("'nine'", repr(rec))
 
+
     @inlineCallbacks
     def test_orderedQuery(self):
         """
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20130104/e99ee2f3/attachment-0001.html>


More information about the calendarserver-changes mailing list