Modify

Opened 6 years ago

Closed 6 years ago

Last modified 6 years ago

#13462 closed defect (fixed)

remove static resource import for db backends

Reported by: Rochi Owned by: Russ Tyndall
Priority: normal Component: TimingAndEstimationPlugin
Severity: normal Keywords:
Cc: Trac Release: 1.2

Description

The dbhelper uses static import for db backends. That produces in Trac 1.2.3 an error if not all db backends are installed.

We use mysql, so the postgresql python bindings were not installed.

We fixed it with:

import trac.db.pool
import trac.db.sqlite_backend
from pkg_resources import DistributionNotFound
try:
    import trac.db.postgres_backend
except DistributionNotFound:
    pass
import trac.db.mysql_backend

This workaround needs still some optimization.

Attachments (0)

Change History (6)

comment:1 Changed 6 years ago by Russ Tyndall

Howdy, I will look into this. I think I am mostly doing this to enable different syntax for specific databases, so I might be able to be more forgiving.

comment:2 Changed 6 years ago by Russ Tyndall

In 17249:

Change db backend import stuff to allow running without all backends installed re #13462

comment:3 Changed 6 years ago by Russ Tyndall

I think you problem should be resolved in version 1.6.0

comment:4 Changed 6 years ago by Russ Tyndall

Resolution: fixed
Status: newclosed

comment:5 Changed 6 years ago by anonymous

Other plugins use this:

dburi = env.config.get('trac', 'database')
if dburi.startswith('sqlite:'):
    pass
elif dburi.startswith('postgres:'):
    pass
elif dburi.startswith('mysql:'):
    pass

For example https://trac-hacks.org/browser/tracmigrateplugin/0.12/tracmigrate/admin.py

comment:6 in reply to:  5 Changed 6 years ago by Rochi

Replying to anonymous:

Other plugins use this:

dburi = env.config.get('trac', 'database')
if dburi.startswith('sqlite:'):
    pass
elif dburi.startswith('postgres:'):
    pass
elif dburi.startswith('mysql:'):
    pass

For example https://trac-hacks.org/browser/tracmigrateplugin/0.12/tracmigrate/admin.py

I think this is a good approach, but the env is actual not available.

@Russ Thx for the very fast fix.

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Russ Tyndall.
The resolution will be deleted. Next status will be 'reopened'.

Add Comment


E-mail address and name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.