[CalendarServer-changes] [9659] CalendarServer/branches/users/glyph/q

source_changes at macosforge.org source_changes at macosforge.org
Sat Aug 11 01:55:30 PDT 2012


Revision: 9659
          http://trac.macosforge.org/projects/calendarserver/changeset/9659
Author:   glyph at apple.com
Date:     2012-08-11 01:55:30 -0700 (Sat, 11 Aug 2012)
Log Message:
-----------
fix the naming convention

Modified Paths:
--------------
    CalendarServer/branches/users/glyph/q/twext/enterprise/dal/record.py
    CalendarServer/branches/users/glyph/q/twext/enterprise/dal/test/test_record.py

Property Changed:
----------------
    CalendarServer/branches/users/glyph/q/

Modified: CalendarServer/branches/users/glyph/q/twext/enterprise/dal/record.py
===================================================================
--- CalendarServer/branches/users/glyph/q/twext/enterprise/dal/record.py	2012-08-11 08:55:29 UTC (rev 9658)
+++ CalendarServer/branches/users/glyph/q/twext/enterprise/dal/record.py	2012-08-11 08:55:30 UTC (rev 9659)
@@ -146,7 +146,13 @@
         (typically, upper-case database names map to lower-case attribute
         names).
         """
-        return columnName.lower()
+        words = columnName.lower().split("_")
+        def cap(word):
+            if word.lower() == 'id':
+                return word.upper()
+            else:
+                return word.capitalize()
+        return words[0] + "".join(map(cap, words[1:]))
 
 
     @classmethod

Modified: CalendarServer/branches/users/glyph/q/twext/enterprise/dal/test/test_record.py
===================================================================
--- CalendarServer/branches/users/glyph/q/twext/enterprise/dal/test/test_record.py	2012-08-11 08:55:29 UTC (rev 9658)
+++ CalendarServer/branches/users/glyph/q/twext/enterprise/dal/test/test_record.py	2012-08-11 08:55:30 UTC (rev 9659)
@@ -215,5 +215,15 @@
         yield self.failUnlessFailure(TestRecord.pop(txn, 234), NoSuchRecord)
 
 
+    def test_columnNamingConvention(self):
+        """
+        The naming convention maps columns C{LIKE_THIS} to be attributes
+        C{likeThis}.
+        """
+        self.assertEqual(Record.namingConvention(u"like_this"), "likeThis")
+        self.assertEqual(Record.namingConvention(u"LIKE_THIS"), "likeThis")
+        self.assertEqual(Record.namingConvention(u"LIKE_THIS_ID"), "likeThisID")
 
 
+
+
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20120811/ae7f1ca7/attachment.html>


More information about the calendarserver-changes mailing list