=== modified file 'python/Makefile.am'
--- a/python/Makefile.am	2008-04-13 21:25:51 +0000
+++ b/python/Makefile.am	2008-04-13 21:51:23 +0000
@@ -1,4 +1,21 @@
 # -*- Mode: Makefile -*-
+##  ndb-bindings: Bindings for the NDB API
+##    Copyright (C) 2006 MySQL, Inc.
+##    
+##    This program is free software; you can redistribute it and/or modify
+##    it under the terms of the GNU General Public License as published by
+##    the Free Software Foundation; either version 2 of the License, or 
+##    (at your option) any later version.
+##    
+##    This program is distributed in the hope that it will be useful,
+##    but WITHOUT ANY WARRANTY; without even the implied warranty of
+##    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+##    GNU General Public License for more details.
+##
+##    You should have received a copy of the GNU General Public License
+##    along with this program; if not, write to the Free Software
+##    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+
 builddir=${top_builddir}/python
 pythonarchdir=$(PYTHON_DIR)
 pythonarch_DATA=${builddir}/mysql/cluster/_ndbapi.so ${builddir}/mysql/cluster/_mgmapi.so

=== modified file 'python/ndbapi.i'
--- a/python/ndbapi.i	2008-04-13 20:59:19 +0000
+++ b/python/ndbapi.i	2008-04-13 21:51:23 +0000
@@ -1,200 +1,61 @@
-// -*- mode: c++ -*- 
-/*  ndb-bindings: Bindings for the NDB API
-    Copyright (C) 2006 MySQL, Inc.
-    
-    This program is free software; you can redistribute it and/or modify
-    it under the terms of the GNU General Public License as published by
-    the Free Software Foundation; either version 2 of the License, or 
-    (at your option) any later version.
-    
-    This program is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-    GNU General Public License for more details.
+/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
+ *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
+ *
+ *  ndb-bindings: Bindings for the NDB API
+ *  Copyright (C) 2008 MySQL
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ */
 
-    You should have received a copy of the GNU General Public License
-    along with this program; if not, write to the Free Software
-    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
-*/
 
 %module ndbapi
 
 %include "ndbapi/ndbglobals.i"
 
 
-
-%typemap(in) asynch_callback_t * cb {
-  
-  if (!PyCallable_Check($input)) {
-    PyErr_SetString(PyExc_TypeError, "Need a callable object!");
-    return NULL;
-  }
-  $1 = new asynch_callback_t;
-  $1->obj = $input;
-  Py_INCREF($input);
-  $1->create_time=0;
- }
-
-%typemap(in) (MYSQL_TIME *) { 
-  if (PyDateTime_Check($input)) { 
-    MYSQL_TIME * dt = (MYSQL_TIME *)malloc(sizeof(MYSQL_TIME));
-    if (dt==NULL) 
-      NDB_exception(NdbApiException,"Failed to allocate a MYSQL_TIME");
-    dt->year = PyDateTime_GET_YEAR($input);
-    dt->month = PyDateTime_GET_MONTH($input);
-    dt->day = PyDateTime_GET_DAY($input);
-    dt->hour = PyDateTime_DATE_GET_HOUR($input);
-    dt->minute = PyDateTime_DATE_GET_MINUTE($input);
-    dt->second = PyDateTime_DATE_GET_SECOND($input);
-    $1 = dt;      
-  } else { 
-    NDB_exception(NdbApiException,"DateTime argument required!");
-  }
- }
+%include "swig/datetime.i"
+
 
 %typemap(in) (const char* anInputString, size_t len) {
   /* Check that we are getting a string */
   if (PyString_Check($input)) {
-    // We are going to try not copying this string, since it's not going to 
+    // We are going to try not copying this string, since it's not going to
     // be modified and we're going to copy it in the main function
-    $1=PyString_AsString($input); 
+    $1=PyString_AsString($input);
     $2=PyString_Size($input);
-  } else { 
+  } else {
     NDB_exception(NdbApiException,"Couldn't convert argument");
   }
  }
 
-%typemap(freearg) (MYSQL_TIME *) {
-  free((MYSQL_TIME *) $1);
- }
-
-typedef int voidint;
-
-
-%runtime %{
-
-// Include python/datetime.h
-
-
-
-  #include <datetime.h>
-
-  
-  %}
-
-
-%{
-  
-
-typedef struct
-asynch_callback_t
-{  
-  PyObject *obj;
-  long long create_time;
-};
-
-/* This function matches the prototype of the normal C callback
-   function for our widget. However, we use the clientdata pointer
-   for holding a reference to a Python callable object. */
-  
-  
-  static void theCallBack(int result,
-			  NdbTransaction *trans,
-			  void *aObject)
-  {
-    PyObject *func, *arglist;
-    PyObject *trans_obj = 0;
-    
-    asynch_callback_t * callback_data = (asynch_callback_t *)aObject;
-    func = (PyObject *) callback_data->obj;   // Get Python callable
-    trans_obj = SWIG_NewPointerObj(SWIG_as_voidptr(trans), SWIGTYPE_p_NdbTransaction, 0 |  0 );
-    arglist = Py_BuildValue("(i,O)",result, trans_obj);             // Build argument list
-    delete callback_data; 
-    PyEval_CallObject(func,arglist);     // Call Python
-    Py_DECREF(func);
-    Py_DECREF(arglist);                  // Trash arglist
-    
-  }
-  
-#define NEW_pyexcept(EXCPT,EPARENT) { PyExc_ ## EXCPT = PyErr_NewException((char *)"mysql.cluster.ndbapi." #EXCPT ,EPARENT,NULL); PyDict_SetItemString(d, #EXCPT ,PyExc_ ## EXCPT); Py_INCREF(PyExc_ ## EXCPT); }
-  
-  PyObject * PyExc_NdbApiException; 
-  PyObject * PyExc_BlobUndefinedException;
-  PyObject * PyExc_NdbApiPermanentException;
-  PyObject * PyExc_NdbApiRuntimeException;
-  PyObject * PyExc_NdbApiTemporaryException;
-  PyObject * PyExc_NdbApiTimeStampOutOfBoundsException;
-  PyObject * PyExc_NdbApiUserErrorPermanentException;
-  PyObject * PyExc_NdbClusterConnectionPermanentException;
-  PyObject * PyExc_NdbClusterConnectionTemporaryException;
-  PyObject * PyExc_NoSuchColumnException;
-  PyObject * PyExc_NoSuchIndexException;
-  PyObject * PyExc_NoSuchTableException;
-  
-#define NDB_exception(excp, msg) { ndb_throw_exception(excp,msg); SWIG_fail; }
-// TODO: Need to support this form of exception
-#define NDB_exception_err(excp, msg, err) { ndb_throw_exception(excp,msg); SWIG_fail; }
-  
-  void ndb_throw_exception(NdbException excp_mod, const char * msg) { 
-    
-    PyObject * exception; 
-    
-    switch (excp_mod) { 
-    case NdbApiException:
-      exception = PyExc_NdbApiException;
-      break; 
-    case BlobUndefinedException:
-      exception = PyExc_BlobUndefinedException;
-      break;
-    case NdbApiPermanentException:
-      exception = PyExc_NdbApiPermanentException;
-      break;
-    case NdbApiRuntimeException:
-      exception = PyExc_NdbApiRuntimeException;
-      break;
-    case NdbApiTemporaryException:
-      exception = PyExc_NdbApiTemporaryException;
-      break;
-    case NdbApiTimeStampOutOfBoundsException:
-      exception = PyExc_NdbApiTimeStampOutOfBoundsException;
-      break;
-    case NdbApiUserErrorPermanentException:
-      exception = PyExc_NdbApiUserErrorPermanentException;
-      break;
-    case NdbClusterConnectionPermanentException:
-      exception = PyExc_NdbClusterConnectionPermanentException;
-      break;
-    case NdbClusterConnectionTemporaryException:
-      exception = PyExc_NdbClusterConnectionTemporaryException;
-      break;
-    case NoSuchColumnException:
-      exception = PyExc_NoSuchColumnException;
-      break;
-    case NoSuchIndexException:
-      exception = PyExc_NoSuchIndexException;
-      break;
-    case NoSuchTableException:
-      exception = PyExc_NoSuchTableException;
-      break;
-    default:
-      exception = PyExc_RuntimeError;
-    }
-    exception = PyExc_NdbApiException;
-    PyErr_SetString(exception,msg);
-    Py_INCREF(exception);  
-  }
-  
-  
-  
-  %}
-
-// %feature("shadow") Ndb_cluster_connection::createNdb(const char*, Int32) %{ 
+
+
+
+
+%include "swig/init.i"
+
+%include "swig/callback.i"
+%include "swig/exception.i"
+
+// %feature("shadow") Ndb_cluster_connection::createNdb(const char*, Int32) %{
 %feature("shadow") Ndb_cluster_connection::createNdb %{
-def createNdb(self, *args):
-  ret=$action(self,*args)
-  ret.__ndb_cluster_connection_ref=(self)
-  return ret
-%}
+  def createNdb(self, *args):
+    ret=$action(self,*args)
+    ret.__ndb_cluster_connection_ref=(self)
+    return ret
+    %}
 
 %include "ndbapi/NdbFactory.i"
 
@@ -204,31 +65,9 @@
 %include "ndbapi/Ndb.i"
 %include "ndbapi/NdbDictionary.i"
 
-%include "ndbapi/NdbTransaction.i" 
-
-
-
-%init %{
-
-
-  ndb_init();
-  
-  PyDateTime_IMPORT;
-
-  NEW_pyexcept(NdbApiException,NULL);
-  NEW_pyexcept(NdbApiRuntimeException,PyExc_NdbApiException);
-  NEW_pyexcept(NdbApiPermanentException,PyExc_NdbApiException);
-  NEW_pyexcept(NdbApiTemporaryException,PyExc_NdbApiException);
-  NEW_pyexcept(NdbApiUserErrorPermanentException,PyExc_NdbApiPermanentException);
-  NEW_pyexcept(NdbClusterConnectionPermanentException,PyExc_NdbApiPermanentException);
-  NEW_pyexcept(NdbClusterConnectionTemporaryException,PyExc_NdbApiTemporaryException);
-  NEW_pyexcept(NdbApiTimeStampOutOfBoundsException,PyExc_NdbApiException);
-  NEW_pyexcept(BlobUndefinedException,PyExc_NdbApiException);
-  NEW_pyexcept(NoSuchColumnException,PyExc_NdbApiException);
-  NEW_pyexcept(NoSuchIndexException,PyExc_NdbApiException);
-  NEW_pyexcept(NoSuchTableException,PyExc_NdbApiException);
-
-%}
+%include "ndbapi/NdbTransaction.i"
+
+
 
 %include "ndbapi/NdbOperation.i"
 
@@ -237,109 +76,13 @@
 %include "ndbapi/NdbIndexScanOperation.i"
 %include "ndbapi/NdbEventOperation.i"
 
+%include "swig/recattr_getvalue.i"
 
 %include "ndbapi/NdbRecAttr.i"
 
-%extend NdbRecAttr {
-
-  %pythoncode %{
-def getValue(self):
-  t=self.getColType()
-
-  if t >= NDB_TYPE_TINYINT and t <= NDB_TYPE_BIGINT and (t%2==0.0):
-    ret = self.getInt32()
-  elif t >= NDB_TYPE_TINYUNSIGNED and t <= NDB_TYPE_BIGUNSIGNED and (t%2==1):
-    ret = self.getUint32()
-  elif t == NDB_TYPE_FLOAT:
-    ret = self.getFloat()
-  elif t == NDB_TYPE_DOUBLE or t == NDB_TYPE_OLDDECIMAL:
-    ret = self.getDouble()
-  elif t >= NDB_TYPE_CHAR and t <= NDB_TYPE_VARBINARY:
-    ret = self.aRef()
-  elif t == NDB_TYPE_DATE: 
-    ret = self.getUint32()
-    year = ret/10000 % 10000
-    month = ret/100 % 100
-    day = ret % 100
-    ret = "%s-%s-%s" % (year,month,day)
-  else:
-    # TODO add newer datatypes here
-    raise NdbApiException, "unknown type"
-  return ret
-  
-    %}
-
-};
 
 %include "ndbapi/NdbError.i"
 %include "ndbapi/NdbBlob.i"
 %include "ndbapi/NdbScanFilter.i"
 
-
-%pythoncode %{ 
-
-NdbApiException=_ndbapi.NdbApiException
-NdbApiPermanentException=_ndbapi.NdbApiPermanentException
-BlobUndefinedException=_ndbapi.BlobUndefinedException
-NdbApiRuntimeException=_ndbapi.NdbApiRuntimeException
-NdbApiTemporaryException=_ndbapi.NdbApiTemporaryException
-NdbApiTimeStampOutOfBoundsException=_ndbapi.NdbApiTimeStampOutOfBoundsException
-NdbApiUserErrorPermanentException=_ndbapi.NdbApiUserErrorPermanentException
-NdbClusterConnectionPermanentException=_ndbapi.NdbClusterConnectionPermanentException
-NdbClusterConnectionTemporaryException=_ndbapi.NdbClusterConnectionTemporaryException
-NoSuchColumnException=_ndbapi.NoSuchColumnException
-NoSuchIndexException=_ndbapi.NoSuchIndexException
-NoSuchTableException=_ndbapi.NoSuchTableException
-
-def connect(connectstring=None,no_retries=0,retry_delay_in_seconds=1,
-            verbose=0,timeout_for_first_alive=1,timeout_after_first_alive=1,*args,**kwargs):
-  """ Provide DBAPI 2.0 support """ 
-  connection=NdbFactory.createNdbClusterConnection(connectstring)
-  connection.connect(no_retries,retry_delay_in_seconds,verbose)
-  connection.wait_until_ready(timeout_for_first_alive,timeout_after_first_alive)
-  return connection
-  
-%}
-
-/*
- Turns out we don't need these, but I'm leaving them here for reference.
-#if defined(SWIGPYTHON)
-%typemap(out) Uint32 {
-  $result = PyInt_FromUnsignedLong((long) $1);
- }
-%typemap(out) Int32 {
-  $result = PyInt_FromLong((long) $1);
- }
-%typemap(out) Uint64 {
-  $result = PyLong_FromUnsignedLongLong((long) $1);
- }
-%typemap(in) Int32 {
-  $1 = (Int32) PyLong_AsLong($input);
- }
-%typemap(in) Uint32 {
-  if ($input < 0) {
-     PyErr_SetString(PyExc_ValueError,"Expected a nonnegative value.");
-     return NULL;
-  }
-  $1 = (Uint32) PyLong_AsUnsignedLong($input);
- }
-%typemap(in) Uint64 {
-  if ($input < 0) {
-     PyErr_SetString(PyExc_ValueError,"Expected a nonnegative value.");
-     return NULL;
-  }
-  $1 = (Uint64) PyLong_AsUnsignedLong($input);
-
- }
-%typemap(typecheck,precedence=SWIG_TYPECHECK_INTEGER) Uint32 {
-   $1 = PyInt_Check($input) ? 1 : 0;
-}
-%typemap(typecheck,precedence=SWIG_TYPECHECK_INTEGER) Uint64 {
-   $1 = PyLong_Check($input) ? 1 : 0;
-}
-%typemap(typecheck,precedence=SWIG_TYPECHECK_INTEGER) Int32 {
-   $1 = PyInt_Check($input) ? 1 : 0;
-}
-#endif
-
-*/
+%include "swig/module_pythoncode.i"

=== modified file 'python/setup.py'
--- a/python/setup.py	2008-04-13 21:08:34 +0000
+++ b/python/setup.py	2008-04-13 21:51:23 +0000
@@ -1,4 +1,6 @@
 #!/usr/bin/env python
+# -*- mode: python; c-basic-offset: 2; indent-tabs-mode: nil; -*-
+#  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
 ##  ndb-bindings: Bindings for the NDB API
 ##    Copyright (C) 2006 MySQL, Inc.
 ##    
@@ -45,7 +47,7 @@
 
 setup(name="python-ndbapi",
       version=version,
-      description=description, 
+      description=description,
       long_description=description,
       author="Monty Taylor",
       author_email="mtaylor@mysql.com",
@@ -55,44 +57,39 @@
       classifiers=filter(None, classifiers.splitlines()),
 
       ext_modules=[
-                    Extension("mysql.cluster._mgmapi",
-                              sources=["mgmapi.cpp"],
-                              libraries=["mgmpp"],
-                              library_dirs=["%s/mgmpp/.libs" % top_builddir],
-                              depends=["%s/interface/mgmapi/%s" % (top_srcdir,f) for f in os.listdir("%s/interface/mgmapi" % top_srcdir)],
-                              language="c++",
-                             
-                              ),
-                    Extension("mysql.cluster._ndbapi",
-                              sources=["ndbapi.cpp"],
-                              library_dirs=["%s/mgmpp/.libs" % top_builddir],
-                              depends=["%s/interface/ndbapi/%s" % (top_srcdir,f) for f in os.listdir("%s/interface/ndbapi" % top_srcdir)],
-                              language="c++",
-                             
-                              ),
-                    Extension("mysql.cluster._events",
-                              sources=["events.cpp"],
-                              libraries=["mgmpp"],
-                              library_dirs=["%s/mgmpp/.libs" % top_builddir],
-                              depends=["%s/interface/mgmapi/%s" % (top_srcdir,f) for f in os.listdir("%s/interface/mgmapi" % top_srcdir)],
-                              language="c++",
-                             
-                              ),
-                    Extension("mysql.cluster._listeners",
-                              sources=["listeners.cpp"],
-                              libraries=["mgmpp"],
-                              library_dirs=["%s/mgmpp/.libs" % top_builddir],
-                              depends=["%s/interface/mgmapi/%s" % (top_srcdir,f) for f in os.listdir("%s/interface/mgmapi" % top_srcdir)],
-                              language="c++",
-                             
-                              ),
+        Extension("mysql.cluster._mgmapi",
+                  sources=["mgmapi.cpp"],
+                  libraries=["mgmpp"],
+                  library_dirs=["%s/mgmpp/.libs" % top_builddir],
+                  depends=["%s/interface/mgmapi/%s" % (top_srcdir,f) for f in os.listdir("%s/interface/mgmapi" % top_srcdir)],
+                  language="c++",
+                  ),
+        Extension("mysql.cluster._ndbapi",
+                  sources=["ndbapi.cpp"],
+                  library_dirs=["%s/mgmpp/.libs" % top_builddir],
+                  depends=["%s/interface/ndbapi/%s" % (top_srcdir,f) for f in os.listdir("%s/interface/ndbapi" % top_srcdir)],
+                  language="c++",
+                  ),
+        Extension("mysql.cluster._events",
+                  sources=["events.cpp"],
+                  libraries=["mgmpp"],
+                  library_dirs=["%s/mgmpp/.libs" % top_builddir],
+                  depends=["%s/interface/mgmapi/%s" % (top_srcdir,f) for f in os.listdir("%s/interface/mgmapi" % top_srcdir)],
+                  language="c++",
+                  ),
+        Extension("mysql.cluster._listeners",
+                  sources=["listeners.cpp"],
+                  libraries=["mgmpp"],
+                  library_dirs=["%s/mgmpp/.libs" % top_builddir],
+                  depends=["%s/interface/mgmapi/%s" % (top_srcdir,f) for f in os.listdir("%s/interface/mgmapi" % top_srcdir)],
+                  language="c++",
+                  ),
 
-                    ],
+        ],
       test_suite = "tests.NdbTest.test_all",
       entry_points = {
         'sqlalchemy.databases': [ 'ndbapi = mysql.cluster.alchemy:dialect' ]
-      },
+        },
       py_modules=["mysql", "mysql.cluster", "mysql.cluster.ndbapi","mysql.cluster.mgmapi","mysql.cluster.events","mysql.cluster.alchemy"]
-      
-     )
+      )
 

=== added directory 'python/swig'
=== added file 'python/swig/callback.i'
--- a/python/swig/callback.i	1970-01-01 00:00:00 +0000
+++ b/python/swig/callback.i	2008-04-13 21:51:23 +0000
@@ -0,0 +1,71 @@
+/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
+ *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
+ *
+ *  ndb-bindings: Bindings for the NDB API
+ *  Copyright (C) 2008 MySQL
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+%typemap(in) asynch_callback_t * cb {
+
+  if (!PyCallable_Check($input)) {
+    PyErr_SetString(PyExc_TypeError, "Need a callable object!");
+    return NULL;
+  }
+  $1 = new asynch_callback_t;
+  $1->obj = $input;
+  Py_INCREF($input);
+  $1->create_time=0;
+ }
+
+%{
+
+
+  typedef struct
+    asynch_callback_t
+  {
+    PyObject *obj;
+    long long create_time;
+  };
+
+/* This function matches the prototype of the normal C callback
+   function for our widget. However, we use the clientdata pointer
+   for holding a reference to a Python callable object. */
+
+
+  static void theCallBack(int result,
+                          NdbTransaction *trans,
+                          void *aObject)
+  {
+    PyObject *func, *arglist;
+    PyObject *trans_obj = 0;
+
+    asynch_callback_t * callback_data = (asynch_callback_t *)aObject;
+    func = (PyObject *) callback_data->obj;   // Get Python callable
+    trans_obj = SWIG_NewPointerObj(SWIG_as_voidptr(trans),
+                                   SWIGTYPE_p_NdbTransaction, 0 |  0 );
+
+    // Build argument list
+    arglist = Py_BuildValue("(i,O)",result, trans_obj);
+
+    delete callback_data;
+    PyEval_CallObject(func,arglist);     // Call Python
+    Py_DECREF(func);
+    Py_DECREF(arglist);                  // Trash arglist
+
+  }
+
+%}

=== added file 'python/swig/datetime.i'
--- a/python/swig/datetime.i	1970-01-01 00:00:00 +0000
+++ b/python/swig/datetime.i	2008-04-13 21:51:23 +0000
@@ -0,0 +1,47 @@
+/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
+ *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
+ *
+ *  ndb-bindings: Bindings for the NDB API
+ *  Copyright (C) 2008 MySQL
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+%runtime %{
+
+#include <datetime.h>
+
+  %}
+
+%typemap(in) (MYSQL_TIME *) {
+  if (PyDateTime_Check($input)) {
+    MYSQL_TIME * dt = (MYSQL_TIME *)malloc(sizeof(MYSQL_TIME));
+    if (dt==NULL)
+      NDB_exception(NdbApiException,"Failed to allocate a MYSQL_TIME");
+    dt->year = PyDateTime_GET_YEAR($input);
+    dt->month = PyDateTime_GET_MONTH($input);
+    dt->day = PyDateTime_GET_DAY($input);
+    dt->hour = PyDateTime_DATE_GET_HOUR($input);
+    dt->minute = PyDateTime_DATE_GET_MINUTE($input);
+    dt->second = PyDateTime_DATE_GET_SECOND($input);
+    $1 = dt;
+  } else {
+    NDB_exception(NdbApiException,"DateTime argument required!");
+  }
+ }
+
+%typemap(freearg) (MYSQL_TIME *) {
+  free((MYSQL_TIME *) $1);
+ }

=== added file 'python/swig/exception.i'
--- a/python/swig/exception.i	1970-01-01 00:00:00 +0000
+++ b/python/swig/exception.i	2008-04-13 21:51:23 +0000
@@ -0,0 +1,101 @@
+/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
+ *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
+ *
+ *  ndb-bindings: Bindings for the NDB API
+ *  Copyright (C) 2008 MySQL
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+
+%{
+#define NEW_pyexcept(EXCPT,EPARENT) { \
+    PyExc_ ## EXCPT = \
+      PyErr_NewException((char *)"mysql.cluster.ndbapi." #EXCPT ,\
+                         EPARENT,NULL);\
+    PyDict_SetItemString(d, #EXCPT ,PyExc_ ## EXCPT);\
+    Py_INCREF(PyExc_ ## EXCPT); }
+
+  PyObject * PyExc_NdbApiException;
+  PyObject * PyExc_BlobUndefinedException;
+  PyObject * PyExc_NdbApiPermanentException;
+  PyObject * PyExc_NdbApiRuntimeException;
+  PyObject * PyExc_NdbApiTemporaryException;
+  PyObject * PyExc_NdbApiTimeStampOutOfBoundsException;
+  PyObject * PyExc_NdbApiUserErrorPermanentException;
+  PyObject * PyExc_NdbClusterConnectionPermanentException;
+  PyObject * PyExc_NdbClusterConnectionTemporaryException;
+  PyObject * PyExc_NoSuchColumnException;
+  PyObject * PyExc_NoSuchIndexException;
+  PyObject * PyExc_NoSuchTableException;
+
+#define NDB_exception(excp, msg) { ndb_throw_exception(excp,msg); SWIG_fail; }
+// TODO: Need to support this form of exception
+#define NDB_exception_err(excp, msg, err) { \
+    ndb_throw_exception(excp,msg);\
+    SWIG_fail; }
+
+  void ndb_throw_exception(NdbException excp_mod, const char * msg) {
+
+    PyObject * exception;
+
+    switch (excp_mod) {
+    case NdbApiException:
+      exception = PyExc_NdbApiException;
+      break;
+    case BlobUndefinedException:
+      exception = PyExc_BlobUndefinedException;
+      break;
+    case NdbApiPermanentException:
+      exception = PyExc_NdbApiPermanentException;
+      break;
+    case NdbApiRuntimeException:
+      exception = PyExc_NdbApiRuntimeException;
+      break;
+    case NdbApiTemporaryException:
+      exception = PyExc_NdbApiTemporaryException;
+      break;
+    case NdbApiTimeStampOutOfBoundsException:
+      exception = PyExc_NdbApiTimeStampOutOfBoundsException;
+      break;
+    case NdbApiUserErrorPermanentException:
+      exception = PyExc_NdbApiUserErrorPermanentException;
+      break;
+    case NdbClusterConnectionPermanentException:
+      exception = PyExc_NdbClusterConnectionPermanentException;
+      break;
+    case NdbClusterConnectionTemporaryException:
+      exception = PyExc_NdbClusterConnectionTemporaryException;
+      break;
+    case NoSuchColumnException:
+      exception = PyExc_NoSuchColumnException;
+      break;
+    case NoSuchIndexException:
+      exception = PyExc_NoSuchIndexException;
+      break;
+    case NoSuchTableException:
+      exception = PyExc_NoSuchTableException;
+      break;
+    default:
+      exception = PyExc_RuntimeError;
+    }
+    exception = PyExc_NdbApiException;
+    PyErr_SetString(exception,msg);
+    Py_INCREF(exception);
+  }
+
+
+
+  %}

=== added file 'python/swig/init.i'
--- a/python/swig/init.i	1970-01-01 00:00:00 +0000
+++ b/python/swig/init.i	2008-04-13 21:51:23 +0000
@@ -0,0 +1,46 @@
+/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
+ *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
+ *
+ *  ndb-bindings: Bindings for the NDB API
+ *  Copyright (C) 2008 MySQL
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+
+typedef int voidint;
+
+%init %{
+
+
+  ndb_init();
+
+  PyDateTime_IMPORT;
+
+  NEW_pyexcept(NdbApiException,NULL);
+  NEW_pyexcept(NdbApiRuntimeException,PyExc_NdbApiException);
+  NEW_pyexcept(NdbApiPermanentException,PyExc_NdbApiException);
+  NEW_pyexcept(NdbApiTemporaryException,PyExc_NdbApiException);
+  NEW_pyexcept(NdbApiUserErrorPermanentException,PyExc_NdbApiPermanentException);
+  NEW_pyexcept(NdbClusterConnectionPermanentException,PyExc_NdbApiPermanentException);
+  NEW_pyexcept(NdbClusterConnectionTemporaryException,PyExc_NdbApiTemporaryException);
+  NEW_pyexcept(NdbApiTimeStampOutOfBoundsException,PyExc_NdbApiException);
+  NEW_pyexcept(BlobUndefinedException,PyExc_NdbApiException);
+  NEW_pyexcept(NoSuchColumnException,PyExc_NdbApiException);
+  NEW_pyexcept(NoSuchIndexException,PyExc_NdbApiException);
+  NEW_pyexcept(NoSuchTableException,PyExc_NdbApiException);
+
+  %}
+

=== added file 'python/swig/module_pythoncode.i'
--- a/python/swig/module_pythoncode.i	1970-01-01 00:00:00 +0000
+++ b/python/swig/module_pythoncode.i	2008-04-13 21:51:23 +0000
@@ -0,0 +1,46 @@
+/* -*- mode: python; c-basic-offset: 2; indent-tabs-mode: nil; -*-
+ *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
+ *
+ *  ndb-bindings: Bindings for the NDB API
+ *  Copyright (C) 2008 MySQL
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+%pythoncode %{
+
+    NdbApiException=_ndbapi.NdbApiException
+    NdbApiPermanentException=_ndbapi.NdbApiPermanentException
+    BlobUndefinedException=_ndbapi.BlobUndefinedException
+    NdbApiRuntimeException=_ndbapi.NdbApiRuntimeException
+    NdbApiTemporaryException=_ndbapi.NdbApiTemporaryException
+    NdbApiTimeStampOutOfBoundsException=_ndbapi.NdbApiTimeStampOutOfBoundsException
+    NdbApiUserErrorPermanentException=_ndbapi.NdbApiUserErrorPermanentException
+    NdbClusterConnectionPermanentException=_ndbapi.NdbClusterConnectionPermanentException
+    NdbClusterConnectionTemporaryException=_ndbapi.NdbClusterConnectionTemporaryException
+    NoSuchColumnException=_ndbapi.NoSuchColumnException
+    NoSuchIndexException=_ndbapi.NoSuchIndexException
+    NoSuchTableException=_ndbapi.NoSuchTableException
+
+    def connect(connectstring=None,no_retries=0,retry_delay_in_seconds=1,
+                verbose=0,timeout_for_first_alive=1,
+                timeout_after_first_alive=1,*args,**kwargs):
+      """ Provide DBAPI 2.0 support """
+      connection=NdbFactory.createNdbClusterConnection(connectstring)
+      connection.connect(no_retries,retry_delay_in_seconds,verbose)
+      connection.wait_until_ready(timeout_for_first_alive,timeout_after_first_alive)
+      return connection
+
+    %}

=== added file 'python/swig/recattr_getvalue.i'
--- a/python/swig/recattr_getvalue.i	1970-01-01 00:00:00 +0000
+++ b/python/swig/recattr_getvalue.i	2008-04-13 21:51:23 +0000
@@ -0,0 +1,51 @@
+/* -*- mode: python; c-basic-offset: 2; indent-tabs-mode: nil; -*-
+ *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
+ *
+ *  ndb-bindings: Bindings for the NDB API
+ *  Copyright (C) 2008 MySQL
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+%extend NdbRecAttr {
+
+  %pythoncode %{
+def getValue(self):
+  t=self.getColType()
+
+  if t >= NDB_TYPE_TINYINT and t <= NDB_TYPE_BIGINT and (t%2==0.0):
+    ret = self.getInt32()
+  elif t >= NDB_TYPE_TINYUNSIGNED and t <= NDB_TYPE_BIGUNSIGNED and (t%2==1):
+    ret = self.getUint32()
+  elif t == NDB_TYPE_FLOAT:
+    ret = self.getFloat()
+  elif t == NDB_TYPE_DOUBLE or t == NDB_TYPE_OLDDECIMAL:
+     ret = self.getDouble()
+  elif t >= NDB_TYPE_CHAR and t <= NDB_TYPE_VARBINARY:
+    ret = self.aRef()
+  elif t == NDB_TYPE_DATE:
+    ret = self.getUint32()
+    year = ret/10000 % 10000
+    month = ret/100 % 100
+    day = ret % 100
+                ret = "%s-%s-%s" % (year,month,day)
+        else:
+# TODO add newer datatypes here
+          raise NdbApiException, "unknown type"
+            return ret
+
+            %}
+
+ };



