# create url.URL object
u = url.make_url(name_or_url)
- entrypoint, dialect_cls = u._get_dialect_plus_entrypoint()
+ entrypoint = u._get_entrypoint()
+ dialect_cls = entrypoint.get_dialect_cls(u)
if kwargs.pop('_coerce_config', False):
def pop_kwarg(key, default=None):
else:
return self.drivername.split('+')[1]
- def _get_dialect_plus_entrypoint(self):
+ def _get_entrypoint(self):
+ """Return the "entry point" dialect class.
+
+ This is normally the dialect itself except in the case when the
+ returned class implements the get_dialect_cls() method.
+
+ """
if '+' not in self.drivername:
name = self.drivername
else:
if hasattr(cls, 'dialect') and \
isinstance(cls.dialect, type) and \
issubclass(cls.dialect, Dialect):
- return cls.dialect, cls.dialect
+ return cls.dialect
else:
- dialect_cls = cls.get_dialect_cls(self)
- return cls, dialect_cls
+ return cls
def get_dialect(self):
"""Return the SQLAlchemy database dialect class corresponding
to this URL's driver name.
"""
- entrypoint, dialect_cls = self._get_dialect_plus_entrypoint()
+ entrypoint = self._get_entrypoint()
+ dialect_cls = entrypoint.get_dialect_cls(self)
return dialect_cls
def translate_connect_args(self, names=[], **kw):
mock_dialect = Mock()
class MyURL(URL):
+ def _get_entrypoint(self):
+ return Dialect
+
def get_dialect(self):
return Dialect
from sqlalchemy.engine import default
url = Mock(
get_dialect=lambda: default.DefaultDialect,
+ _get_entrypoint=lambda: default.DefaultDialect,
translate_connect_args=lambda: {}, query={},)
eng = testing_engine(
url, options=dict(module=dbapi, _initialize=initialize))