Skip to content

Commit 7018ac4

Browse files
author
Alexander Smishlajev
committed
for MySQL connection, password argument is called 'passwd'.
Have own version of connection_dict() returning dictionary suitable for MySQL connections. trim trailing spaces; fix vim modeline.
1 parent 804fb6e commit 7018ac4

File tree

1 file changed

+19
-12
lines changed

1 file changed

+19
-12
lines changed

roundup/backends/back_mysql.py

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,17 @@
3939
import os, shutil
4040
from MySQLdb.constants import ER
4141

42+
def connection_dict(config):
43+
d = rdbms_common.connection_dict(config, 'db')
44+
if d.has_key('password'):
45+
d['passwd'] = d['password']
46+
del d['password']
47+
return d
48+
4249
def db_nuke(config):
4350
"""Clear all database contents and drop database itself"""
4451
if db_exists(config):
45-
kwargs = rdbms_common.connection_dict(config)
52+
kwargs = connection_dict(config)
4653
conn = MySQLdb.connect(**kwargs)
4754
try:
4855
conn.select_db(config.RDBMS_NAME)
@@ -70,7 +77,7 @@ def db_nuke(config):
7077

7178
def db_create(config):
7279
"""Create the database."""
73-
kwargs = rdbms_common.connection_dict(config)
80+
kwargs = connection_dict(config)
7481
conn = MySQLdb.connect(**kwargs)
7582
cursor = conn.cursor()
7683
command = "CREATE DATABASE %s"%config.RDBMS_NAME
@@ -81,7 +88,7 @@ def db_create(config):
8188

8289
def db_exists(config):
8390
"""Check if database already exists."""
84-
kwargs = rdbms_common.connection_dict(config)
91+
kwargs = connection_dict(config)
8592
conn = MySQLdb.connect(**kwargs)
8693
try:
8794
try:
@@ -125,7 +132,7 @@ class Database(Database):
125132
}
126133

127134
def sql_open_connection(self):
128-
kwargs = rdbms_common.connection_dict(config, 'db')
135+
kwargs = connection_dict(self.config)
129136
self.config.logging.getLogger('hyperdb').info('open database %r'%(
130137
kwargs['db'],))
131138
try:
@@ -136,7 +143,7 @@ def sql_open_connection(self):
136143
cursor.execute("SET AUTOCOMMIT=OFF")
137144
cursor.execute("START TRANSACTION")
138145
return (conn, cursor)
139-
146+
140147
def open_connection(self):
141148
# make sure the database actually exists
142149
if not db_exists(self.config):
@@ -218,7 +225,7 @@ def add_new_columns_v2(self):
218225
if properties.has_key(name):
219226
# re-create and populate the new table
220227
self.create_multilink_table(klass, name)
221-
sql = '''insert into %s (linkid, nodeid) values
228+
sql = '''insert into %s (linkid, nodeid) values
222229
(%s, %s)'''%(tn, self.arg, self.arg)
223230
for linkid, nodeid in rows:
224231
self.sql(sql, (int(linkid), int(nodeid)))
@@ -259,7 +266,7 @@ def add_new_columns_v2(self):
259266
v = date.Interval(v)
260267
elif isinstance(prop, Password) and v is not None:
261268
v = password.Password(encrypted=v)
262-
elif (isinstance(prop, Boolean) or
269+
elif (isinstance(prop, Boolean) or
263270
isinstance(prop, Number)) and v is not None:
264271
v = float(v)
265272

@@ -323,7 +330,7 @@ def add_new_columns_v2(self):
323330
journaltag, action, params)
324331

325332
# make sure the normal schema update code doesn't try to
326-
# change things
333+
# change things
327334
self.database_schema['tables'][cn] = klass.schema()
328335

329336
def fix_version_2_tables(self):
@@ -379,7 +386,7 @@ def drop_class_table_indexes(self, cn, key):
379386
self.sql(index_sql)
380387

381388
def create_journal_table(self, spec):
382-
''' create the journal table for a class given the spec and
389+
''' create the journal table for a class given the spec and
383390
already-determined cols
384391
'''
385392
# journal table
@@ -605,7 +612,7 @@ def filter(self, search_matches, filterspec, sort=(None,None),
605612
args.append(dc(date_rng.to_value))
606613
except ValueError:
607614
# If range creation fails - ignore that search parameter
608-
pass
615+
pass
609616
elif isinstance(propclass, Interval):
610617
# filter using the __<prop>_int__ column
611618
if isinstance(v, type([])):
@@ -624,7 +631,7 @@ def filter(self, search_matches, filterspec, sort=(None,None),
624631
args.append(date_rng.to_value.as_seconds())
625632
except ValueError:
626633
# If range creation fails - ignore that search parameter
627-
pass
634+
pass
628635
else:
629636
if isinstance(v, type([])):
630637
s = ','.join([a for x in v])
@@ -743,4 +750,4 @@ class IssueClass(MysqlClass, rdbms_common.IssueClass):
743750
class FileClass(MysqlClass, rdbms_common.FileClass):
744751
pass
745752

746-
#vim: set et
753+
# vim: set et sts=4 sw=4 :

0 commit comments

Comments
 (0)