diff roundup/backends/back_mysql.py @ 5075:04a8022ae0de

Remove 'import *' statement from dist/backends/back_mysql.py There are various 'import *' statements scattered through the code which are generally not a good thing. These should be fairly safe changes, but I'll commit them one file at a time to make it easier to track down issues with a bisect if they crop up later.
author John Kristensen <john@jerrykan.com>
date Fri, 10 Jun 2016 18:14:36 +1000
parents e424987d294a
children e74c3611b138
line wrap: on
line diff
--- a/roundup/backends/back_mysql.py	Fri Jun 10 17:24:39 2016 +1000
+++ b/roundup/backends/back_mysql.py	Fri Jun 10 18:14:36 2016 +1000
@@ -33,7 +33,7 @@
 '''
 __docformat__ = 'restructuredtext'
 
-from roundup.backends.rdbms_common import *
+from roundup import date, hyperdb, password
 from roundup.backends import rdbms_common
 import MySQLdb
 import os, shutil
@@ -109,7 +109,7 @@
     return 1
 
 
-class Database(Database):
+class Database(rdbms_common.Database):
     arg = '%s'
 
     # used by some code to switch styles of query
@@ -151,7 +151,7 @@
         try:
             conn = MySQLdb.connect(**kwargs)
         except MySQLdb.OperationalError, message:
-            raise DatabaseError, message
+            raise hyperdb.DatabaseError, message
         cursor = conn.cursor()
         cursor.execute("SET AUTOCOMMIT=0")
         lvl = isolation_levels [self.config.RDBMS_ISOLATION_LEVEL]
@@ -173,7 +173,7 @@
                 raise
         except MySQLdb.ProgrammingError, message:
             if message[0] != ER.NO_SUCH_TABLE:
-                raise DatabaseError, message
+                raise hyperdb.DatabaseError, message
             self.init_dbschema()
             self.sql("CREATE TABLE `schema` (`schema` TEXT) ENGINE=%s"%
                 self.mysql_backend)
@@ -295,16 +295,16 @@
                     if first:
                         cols.append('_' + name)
                     prop = properties[name]
-                    if isinstance(prop, Date) and v is not None:
+                    if isinstance(prop, hyperdb.Date) and v is not None:
                         v = date.Date(v)
-                    elif isinstance(prop, Interval) and v is not None:
+                    elif isinstance(prop, hyperdb.Interval) and v is not None:
                         v = date.Interval(v)
-                    elif isinstance(prop, Password) and v is not None:
+                    elif isinstance(prop, hyperdb.Password) and v is not None:
                         v = password.Password(encrypted=v)
-                    elif isinstance(prop, Integer) and v is not None:
+                    elif isinstance(prop, hyperdb.Integer) and v is not None:
                         v = int(v)
-                    elif (isinstance(prop, Boolean) or
-                            isinstance(prop, Number)) and v is not None:
+                    elif (isinstance(prop, hyperdb.Boolean) or
+                            isinstance(prop, hyperdb.Number)) and v is not None:
                         v = float(v)
 
                     # convert to new MySQL data type
@@ -316,7 +316,7 @@
                     l.append(e)
 
                     # Intervals store the seconds value too
-                    if isinstance(prop, Interval):
+                    if isinstance(prop, hyperdb.Interval):
                         if first:
                             cols.append('__' + name + '_int__')
                         if v is not None:
@@ -420,7 +420,7 @@
 
         # create index for key property
         if spec.key:
-            if isinstance(spec.properties[spec.key], String):
+            if isinstance(spec.properties[spec.key], hyperdb.String):
                 idx = spec.key + '(255)'
             else:
                 idx = spec.key
@@ -435,7 +435,7 @@
     def add_class_key_required_unique_constraint(self, cn, key):
         # mysql requires sizes on TEXT indexes
         prop = self.classes[cn].getprops()[key]
-        if isinstance(prop, String):
+        if isinstance(prop, hyperdb.String):
             sql = '''create unique index _%s_key_retired_idx
                 on _%s(__retired__, _%s(255))'''%(cn, cn, key)
         else:
@@ -446,7 +446,7 @@
     def create_class_table_key_index(self, cn, key):
         # mysql requires sizes on TEXT indexes
         prop = self.classes[cn].getprops()[key]
-        if isinstance(prop, String):
+        if isinstance(prop, hyperdb.String):
             sql = 'create index _%s_%s_idx on _%s(_%s(255))'%(cn, key, cn, key)
         else:
             sql = 'create index _%s_%s_idx on _%s(_%s)'%(cn, key, cn, key)

Roundup Issue Tracker: http://roundup-tracker.org/