diff -bur -x '*.pyc' sqlobject_orig/dbconnection.py sqlobject/dbconnection.py
--- sqlobject_orig/dbconnection.py	2006-12-18 12:12:54.000000000 +0100
+++ sqlobject/dbconnection.py	2006-12-30 17:36:43.006283200 +0100
@@ -224,8 +224,26 @@
         DBConnection.__init__(self, **kw)
         self._binaryType = type(self.module.Binary(''))

+    def _robustConnectionHack( self, conn ):
+        try:
+            import MySQLdb
+            conn.ping()
+        except ImportError:
+            pass # No MySQLdb module installed.
+        except AttributeError:
+            pass # SQLite connections have not ping() method.
+        except MySQLdb.OperationalError, e:
+            if e.args[ 0 ] in ( 2006, 2013 ): # SERVER_GONE or SERVER_LOST error
+                print 'reconnecting because of', e
+                ##self.cache.clear()
+                conn = self.makeConnection()
+        return conn
+
     def _runWithConnection(self, meth, *args):
         conn = self.getConnection()
+
+        conn = self._robustConnectionHack( conn )
+
         try:
             val = meth(conn, *args)
         finally:
@@ -749,6 +767,8 @@
 class Iteration(object):

     def __init__(self, dbconn, rawconn, select, keepConnection=False):
+        rawconn = dbconn._robustConnectionHack( rawconn )
+
         self.dbconn = dbconn
         self.rawconn = rawconn
         self.select = select
