Edgewall Software
Modify

Opened 15 years ago

Closed 15 years ago

Last modified 15 years ago

#8340 closed defect (fixed)

Type error in init_db() on environment creation with debug_sql = true

Reported by: ebray Owned by: Remy Blank
Priority: normal Milestone: 0.11.5
Component: general Version: devel
Severity: normal Keywords:
Cc: Branch:
Release Notes:
API Changes:
Internal Changes:

Description

I just started playing around with the new-ish debug_sql option in my development environment, and have found it incredibly useful.

So much so in fact that I enabled it in my global trac.ini while debugging a particular problem. With debug_sql enabled during environment initialization, a 'log' argument is passed to the DB connector's init_db() method. Here's the full traceback:

Traceback (most recent call last):
  File "/mnt/hgfs/home/Source/omnipoint/trunk/OmniPoint/Source/Imports/trac/trac/admin/console.py", line 591, in do_initenv
    options=options)
  File "/mnt/hgfs/home/Source/omnipoint/trunk/OmniPoint/Source/Imports/trac/trac/env.py", line 204, in __init__
    self.create(options)
  File "/mnt/hgfs/home/Source/omnipoint/trunk/OmniPoint/Source/Imports/trac/trac/env.py", line 327, in create
    DatabaseManager(self).init_db()
  File "/mnt/hgfs/home/Source/omnipoint/trunk/OmniPoint/Source/Imports/trac/trac/db/api.py", line 74, in init_db
    connector.init_db(**args)
TypeError: init_db() got an unexpected keyword argument 'log'

This affects all three DB backends. The solution, of course, is to add the 'log' argument to the init_db() method for those components.

But this also raises the point that maybe the signature for the get_connection() and init_db() methods of IDatabaseConnector should be made a little more specific. Maybe something like (path, params={}, log=None), given that all three of the officially supported connectors require those three arguments as a minimum, and that as we see in this case, if one of those is missing from the implementation, there are situations where the whole thing can break.

Attachments (0)

Change History (6)

comment:1 by Christian Boos, 15 years ago

Milestone: 0.11.5

Good catch, I have effectively forgotten to test environment creation with this option on.

comment:2 by Christian Boos, 15 years ago

Milestone: 0.11.60.11.5

comment:3 by Remy Blank, 15 years ago

Owner: set to Remy Blank

I'll fix that one.

comment:4 by Remy Blank, 15 years ago

Resolution: fixed
Status: newclosed

Fixed in [8311]. I have changed the signature of get_connection() and init_db() in IDatabaseConnector to (path, log=None, **kwargs), as path is always present, and log must be supported. params, OTOH, is not always present.

in reply to:  4 ; comment:5 by Christian Boos, 15 years ago

Replying to rblank:

I have changed the signature of get_connection() and init_db() in IDatabaseConnector to (path, log=None, **kwargs), as path is always present, and log must be supported. params, OTOH, is not always present.

I agree with above, but then the actual order of the parameters in the corresponding methods in the various backends should probably be changed as well to match this.

Not that it makes a difference as we only call those methods with ...(**args) currently, but it's better to be consistent.

in reply to:  5 comment:6 by Remy Blank, 15 years ago

Replying to cboos:

I agree with above, but then the actual order of the parameters in the corresponding methods in the various backends should probably be changed as well to match this.

I almost did this, and then I thought "it works now, better not break it". Anyway, done in [8316].

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Remy Blank.
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from Remy Blank to the specified user.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.