Skip to content

Commit 6110b45

Browse files
author
Richard Jones
committed
handle ~/.my.cnf files for MySQL defaults [SF#1096031]
1 parent 774a952 commit 6110b45

File tree

4 files changed

+24
-7
lines changed

4 files changed

+24
-7
lines changed

CHANGES.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ Fixed:
1313
- fix setup.py to work with <Python2.3 (sf bug 1082801)
1414
- fix permissions checks in cgi templating (sf bug 1082755)
1515
- fix "Users may only edit their issues" example in docs
16+
- handle ~/.my.cnf files for MySQL defaults (sf bug 1096031)
1617

1718

1819
2004-12-08 0.8.0b1

roundup/backends/back_postgresql.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#$Id: back_postgresql.py,v 1.27 2005-01-08 11:25:23 jlgijsbers Exp $
1+
#$Id: back_postgresql.py,v 1.28 2005-01-13 05:02:18 richard Exp $
22
#
33
# Copyright (c) 2003 Martynas Sklyzmantas, Andrey Lebedev <[email protected]>
44
#
@@ -15,6 +15,15 @@
1515
from roundup import hyperdb, date
1616
from roundup.backends import rdbms_common
1717

18+
def connection_dict(config, dbnamestr=None):
19+
''' read_default_group is MySQL-specific, ignore it '''
20+
d = rdbms_common.connection_dict(config, dbnamestr)
21+
if d.has_key('read_default_group'):
22+
del d['read_default_group']
23+
if d.has_key('read_default_file'):
24+
del d['read_default_file']
25+
return d
26+
1827
def db_create(config):
1928
"""Clear all database contents and drop database itself"""
2029
command = 'CREATE DATABASE %s'%config.RDBMS_NAME
@@ -34,7 +43,7 @@ def db_command(config, command):
3443
'''Perform some sort of database-level command. Retry 10 times if we
3544
fail by conflicting with another user.
3645
'''
37-
template1 = rdbms_common.connection_dict(config)
46+
template1 = connection_dict(config)
3847
template1['database'] = 'template1'
3948

4049
try:
@@ -71,7 +80,7 @@ def pg_command(cursor, command):
7180

7281
def db_exists(config):
7382
"""Check if database already exists"""
74-
db = rdbms_common.connection_dict(config, 'database')
83+
db = connection_dict(config, 'database')
7584
try:
7685
conn = psycopg.connect(**db)
7786
conn.close()
@@ -86,7 +95,7 @@ class Database(rdbms_common.Database):
8695
implements_intersect = 1
8796

8897
def sql_open_connection(self):
89-
db = rdbms_common.connection_dict(self.config, 'database')
98+
db = connection_dict(self.config, 'database')
9099
self.config.logging.getLogger('hyperdb').info('open database %r'%(
91100
db['database'],))
92101
try:

roundup/backends/rdbms_common.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# $Id: rdbms_common.py,v 1.146 2005-01-08 16:16:59 jlgijsbers Exp $
1+
# $Id: rdbms_common.py,v 1.147 2005-01-13 05:02:19 richard Exp $
22
''' Relational database (SQL) backend common code.
33
44
Basics:
@@ -68,7 +68,8 @@ def connection_dict(config, dbnamestr=None):
6868
d = { }
6969
if dbnamestr:
7070
d[dbnamestr] = config.RDBMS_NAME
71-
for name in 'host', 'port', 'password', 'user':
71+
for name in ('host', 'port', 'password', 'user', 'read_default_group',
72+
'read_default_file'):
7273
cvar = 'RDBMS_'+name.upper()
7374
if config[cvar] is not None:
7475
d[name] = config[cvar]

roundup/configuration.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Roundup Issue Tracker configuration support
22
#
3-
# $Id: configuration.py,v 1.23 2004-11-18 14:02:25 a1s Exp $
3+
# $Id: configuration.py,v 1.24 2005-01-13 05:02:18 richard Exp $
44
#
55
__docformat__ = "restructuredtext"
66

@@ -484,6 +484,12 @@ class NullableFilePathOption(NullableOption, FilePathOption):
484484
(NullableOption, 'password', 'roundup',
485485
"Database user password.",
486486
['MYSQL_DBPASSWORD']),
487+
(NullableOption, 'read_default_file', '~/.my.cnf',
488+
"Name of the MySQL defaults file.\n"
489+
"Only used in MySQL connections."),
490+
(NullableOption, 'read_default_group', 'roundup',
491+
"Name of the group to use in the MySQL defaults file (.my.cnf).\n"
492+
"Only used in MySQL connections."),
487493
), "Settings in this section are used"
488494
" by Postgresql and MySQL backends only"
489495
),

0 commit comments

Comments
 (0)