[CalendarServer-changes] [1197] CalendarServer/branches/users/cdaboo/sqlprops-1126/twistedcaldav/sql .py

source_changes at macosforge.org source_changes at macosforge.org
Fri Feb 16 13:43:27 PST 2007


Revision: 1197
          http://trac.macosforge.org/projects/calendarserver/changeset/1197
Author:   cdaboo at apple.com
Date:     2007-02-16 13:43:26 -0800 (Fri, 16 Feb 2007)

Log Message:
-----------
Add an option to allow TEXT values returned from the database come back as str rather than unicode. This
avoids the extra cost of doing a utf-8 encode.

Modified Paths:
--------------
    CalendarServer/branches/users/cdaboo/sqlprops-1126/twistedcaldav/sql.py

Modified: CalendarServer/branches/users/cdaboo/sqlprops-1126/twistedcaldav/sql.py
===================================================================
--- CalendarServer/branches/users/cdaboo/sqlprops-1126/twistedcaldav/sql.py	2007-02-16 21:41:49 UTC (rev 1196)
+++ CalendarServer/branches/users/cdaboo/sqlprops-1126/twistedcaldav/sql.py	2007-02-16 21:43:26 UTC (rev 1197)
@@ -35,14 +35,16 @@
     A generic SQL database.
     """
 
-    def __init__(self, dbpath, version):
+    def __init__(self, dbpath, version, utf8=False):
         """
-        @param resource: the L{twistedcaldav.static.CalDAVFile} resource to
-            index. C{resource} must be a calendar collection (ie.
-            C{resource.isPseudoCalendarCollection()} returns C{True}.)
+        @param dppath: C{str} containing the file path to the database file.
+        @param version: C{str} containing the version for the database schema.
+        @param utf8: C{True} if utf8 encoded C{str} should be returned for SQl TEXT data,
+            C{False} if C{unicode} should be returned.
         """
         self.dbpath = dbpath
         self.version = version
+        self.utf8 = utf8
 
     def _db_type(self):
         """
@@ -58,6 +60,8 @@
         if not hasattr(self, "_db_connection"):
             db_filename = self.dbpath
             self._db_connection = sqlite.connect(db_filename)
+            if self.utf8:
+                self._db_connection.text_factory = str
 
             #
             # Set up the schema

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20070216/1780fe34/attachment.html


More information about the calendarserver-changes mailing list