clean up entrypoint thing
Issue #2462
resolved
use this approach and provide sqlalchemy.dialect.register(). also write some damn tests.
class PluginLoader(object):
def __init__(self, group):
self.group = group
self.impls = {}
def load(self, name):
if name in self.impls:
return self.impls[name](name)()
else:
import pkg_resources
for impl in pkg_resources.iter_entry_points(
self.group,
name):
self.impls[name](name) = impl.load
return impl.load()
else:
raise Exception(
"Can't load plugin %s %s" %
(self.group, name))
def register(self, name, modulepath, objname):
def load():
mod = __import__(modulepath)
for token in modulepath.split(".")[1:](1:):
mod = getattr(mod, token)
return getattr(mod, objname)
self.impls[name](name) = load
Comments (6)
-
reporter -
reporter see https://bitbucket.org/evax/pymysql_sa/wiki/Home as an example 3rd party dialect.
-
reporter - attached 2462.patch
initial patch
-
reporter 71c00115747d2fb13423b0b18e728b402f117528 for that one in the 0.8 branch
-
reporter - changed status to resolved
-
reporter - removed milestone
Removing milestone: 0.8.0b1 (automated comment)
- Log in to comment
disturbing here is that at some point we added a system to handle entrypoints like
mysql+myspecialdriver
, but we are using an inconsistent API in that in that case, we look for the attribute "dialect", but in the case ofmydatabase
we assume the entry point is the dialect class itself. This is totally wrong. The entrypoint needs to point to the same thing in all cases.