Login | Register
My pages Projects Community openCollabNet

Discussions > commits > svn commit: r290 - trunk/current/db/mysql/mysql.py

Project highlights: Stable Version: 1.6.1, Development Version: 1.7.6

current
Discussion topic

Back to topic list

svn commit: r290 - trunk/current/db/mysql/mysql.py

Reply

Author jjneely
Full name Jack Neely
Date 2006-09-15 14:51:19 PDT
Message Author: jjneely
Date: 2006-09-15 14:51:19-0700
New Revision: 290

Modified:
   trunk/current/db/mysql/mysql.py

Log:
The MySQL wrappers returned the pointer to the propper method but
didn't actually wrap the call. This properly wraps the execute() call.


Modified: trunk/current/db/mysql/mysql.py
Url: http://current.tigri​s.org/source/browse/​current/trunk/curren​t/db/mysql/mysql.py?​view=diff&rev=29​0&p1=trunk/curre​nt/db/mysql/mysql.py​&p2=trunk/curren​t/db/mysql/mysql.py​&r1=289&r2=29​0
====================​====================​====================​==================
--- trunk/current/db/mysql/mysql.py (original)
+++ trunk/current/db/mysql/mysql.py 2006-09-15 14:51:19-0700
@@ -18,14 +18,31 @@
 
         return getattr(self.sdb.conn, name)
 
-class Cursor(Connection):
+class Cursor(object):
+
+ def __init__(self, sdb):
+ self.sdb = sdb
+ self.__method = None
 
     def __getattr__(self, name):
         if self.sdb.cursor == None:
             self.sdb.getCursor()
-
- try:
+
+ if name == "execute":
+ self.__method = name
+ return self.__wrapper
+ else:
             return getattr(self.sdb.cursor, name)
+
+ def __wrapper(self, *args, **kwargs):
+ try:
+ func = getattr(self.sdb.cursor, self.__method)
+ except TypeError:
+ log(CRITICAL, "BUG: MySQL cursor wrapper blew up.")
+ raise
+
+ try:
+ return func(*args, **kwargs)
         except MySQLdb.OperationalError, e:
             log(DEBUG2, "OperationalError: e.args = %s" % str(e.args))
             if e.args[0] in (2006, 2013):
@@ -33,7 +50,8 @@
                 self.sdb.conn = None
                 self.sdb.cursor = None
                 self.sdb.getCursor()
- return getattr(self.sdb.cursor, name)
+ func = getattr(self.sdb.cursor, self.__method)
+ return func(*args, **kwargs)
             else:
                 raise

« Previous message in topic | 1 of 1 | Next message in topic »

Messages

Show all messages in topic

svn commit: r290 - trunk/current/db/mysql/mysql.py jjneely Jack Neely 2006-09-15 14:51:19 PDT
Messages per page: