[CalendarServer-changes] [7149] CalendarServer/branches/users/glyph/oracle/txdav/base/datastore/ dbapiclient.py

source_changes at macosforge.org source_changes at macosforge.org
Mon Mar 7 19:06:56 PST 2011


Revision: 7149
          http://trac.macosforge.org/projects/calendarserver/changeset/7149
Author:   glyph at apple.com
Date:     2011-03-07 19:06:56 -0800 (Mon, 07 Mar 2011)
Log Message:
-----------
misc oracle fixes, and preflight that sets timestamp format for a debugging aid

Modified Paths:
--------------
    CalendarServer/branches/users/glyph/oracle/txdav/base/datastore/dbapiclient.py

Modified: CalendarServer/branches/users/glyph/oracle/txdav/base/datastore/dbapiclient.py
===================================================================
--- CalendarServer/branches/users/glyph/oracle/txdav/base/datastore/dbapiclient.py	2011-03-08 03:06:42 UTC (rev 7148)
+++ CalendarServer/branches/users/glyph/oracle/txdav/base/datastore/dbapiclient.py	2011-03-08 03:06:56 UTC (rev 7149)
@@ -82,6 +82,7 @@
             newRow = []
             for column in row:
                 newRow.append(mapOracleOutputType(column))
+            accum.append(newRow)
         return accum
 
 
@@ -108,6 +109,8 @@
                 # it is:
                 v = self.var(cx_Oracle.CLOB, len(arg) + 1)
                 v.setvalue(0, arg)
+            else:
+                v = arg
             realArgs.append(v)
         return super(OracleCursorWrapper, self).execute(sql, realArgs)
 
@@ -171,7 +174,7 @@
 
 
 
-class OracleConnectionWrapper(DBAPIConnector):
+class OracleConnectionWrapper(DiagnosticConnectionWrapper):
 
     wrapper = OracleCursorWrapper
 
@@ -190,10 +193,28 @@
 
     def __init__(self, dsn):
         super(OracleConnector, self).__init__(
-            cx_Oracle, lambda whatever: None, dsn, threaded=True)
+            cx_Oracle, oraclePreflight, dsn, threaded=True)
 
 
 
+def oraclePreflight(connection):
+    """
+    Pre-flight function for Oracle connections: set the timestamp format to be
+    something closely resembling our default assumption from Postgres.
+    """
+    c = connection.cursor()
+    c.execute(
+        "alter session set NLS_TIMESTAMP_FORMAT = "
+        "'YYYY-MM-DD HH24:MI:SS.FF'"
+    )
+    c.execute(
+        "alter session set NLS_TIMESTAMP_TZ_FORMAT = "
+        "'YYYY-MM-DD HH:MI:SS.FF+TZH:TZM'"
+    )
+    connection.commit()
+    c.close()
+
+
 def postgresPreflight(connection):
     """
     Pre-flight function for PostgreSQL connections: enable standard conforming
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20110307/52ce5557/attachment.html>


More information about the calendarserver-changes mailing list