diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2020-03-03 16:03:39 -0500 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2020-03-03 16:06:06 -0500 |
commit | 598f2f7e557073f29563d4d567f43931fc03013f (patch) | |
tree | c3f428e86022564dd4dedfa9718dbfddd0724425 /lib/sqlalchemy/engine/interfaces.py | |
parent | 4c81d99bab0e884473abfcb573772aa5d94264c7 (diff) | |
download | sqlalchemy-598f2f7e557073f29563d4d567f43931fc03013f.tar.gz |
Don't import provision.py unconditionally
Removed the imports for provision.py from each dialect
and instead added a call in the central provision.py to
a new dialect level method load_provisioning(). The
provisioning registry works in the same way, so an existing
dialect that is using the provision.py system right now
by importing it as part of the package will still continue to
function. However, to avoid pulling in the testing package when
the dialect is used in a non-testing context, the new hook may be
used. Also removed a module-level dependency
of the testing framework on the orm package.
Revised an internal change to the test system added as a result of
:ticket:`5085` where a testing-related module per dialect would be loaded
unconditionally upon making use of that dialect, pulling in SQLAlchemy's
testing framework as well as the ORM into the module import space. This
would only impact initial startup time and memory to a modest extent,
however it's best that these additional modules aren't reverse-dependent on
straight Core usage.
Fixes: #5180
Change-Id: I6355601da5f6f44d85a2bbc3acb5928559942b9c
Diffstat (limited to 'lib/sqlalchemy/engine/interfaces.py')
-rw-r--r-- | lib/sqlalchemy/engine/interfaces.py | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/lib/sqlalchemy/engine/interfaces.py b/lib/sqlalchemy/engine/interfaces.py index 04e572c2d..84def853f 100644 --- a/lib/sqlalchemy/engine/interfaces.py +++ b/lib/sqlalchemy/engine/interfaces.py @@ -866,6 +866,35 @@ class Dialect(object): return cls @classmethod + def load_provisioning(cls): + """set up the provision.py module for this dialect. + + For dialects that include a provision.py module that sets up + provisioning followers, this method should initiate that process. + + A typical implementation would be:: + + @classmethod + def load_provisioning(cls): + __import__("mydialect.provision") + + The default method assumes a module named ``provision.py`` inside + the owning package of the current dialect, based on the ``__module__`` + attribute:: + + @classmethod + def load_provisioning(cls): + package = ".".join(cls.__module__.split(".")[0:-1]) + try: + __import__(package + ".provision") + except ImportError: + pass + + .. versionadded:: 1.3.14 + + """ + + @classmethod def engine_created(cls, engine): """A convenience hook called before returning the final :class:`.Engine`. |