From e00f796d9c075fe22478f56f6439c2ee6532e657 Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Sat, 30 May 2009 01:05:25 +0000 Subject: [PATCH] - removed the connect() method of metadata,threadlocalmetadata - removed import of "thread" which is unused, is not "public" in py3k anyway --- 06CHANGES | 4 +++ lib/sqlalchemy/engine/threadlocal.py | 2 +- lib/sqlalchemy/pool.py | 2 +- lib/sqlalchemy/schema.py | 48 +--------------------------- lib/sqlalchemy/util.py | 5 +-- test/dialect/sqlite.py | 4 +-- test/engine/bind.py | 2 +- 7 files changed, 11 insertions(+), 56 deletions(-) diff --git a/06CHANGES b/06CHANGES index 22b7fbf2f9..4594bb519b 100644 --- a/06CHANGES +++ b/06CHANGES @@ -13,6 +13,10 @@ create_engine(... isolation_level="..."); available on postgresql and sqlite. [ticket:443] +- schema + - metadata.connect() and threadlocalmetadata.connect() have been removed. + - new CreateTable,DropTable,CreateSequence,DropSequence, etc. + - dialect refactor - the "owner" keyword argument is removed from Table. Use "schema" to represent any namespaces to be prepended to the table name. diff --git a/lib/sqlalchemy/engine/threadlocal.py b/lib/sqlalchemy/engine/threadlocal.py index ec1a8f5f85..27d857623e 100644 --- a/lib/sqlalchemy/engine/threadlocal.py +++ b/lib/sqlalchemy/engine/threadlocal.py @@ -174,7 +174,7 @@ class TLEngine(base.Engine): """Construct a new TLEngine.""" super(TLEngine, self).__init__(*args, **kwargs) - self.context = util.ThreadLocal() + self.context = util.threading.local() proxy = kwargs.get('proxy') if proxy: diff --git a/lib/sqlalchemy/pool.py b/lib/sqlalchemy/pool.py index f96e1215c4..4173a78786 100644 --- a/lib/sqlalchemy/pool.py +++ b/lib/sqlalchemy/pool.py @@ -20,7 +20,7 @@ import weakref, time, threading from sqlalchemy import exc, log from sqlalchemy import queue as sqla_queue -from sqlalchemy.util import thread, threading, pickle, as_interface +from sqlalchemy.util import threading, pickle, as_interface proxies = {} diff --git a/lib/sqlalchemy/schema.py b/lib/sqlalchemy/schema.py index d3cdeee002..5d46a9928e 100644 --- a/lib/sqlalchemy/schema.py +++ b/lib/sqlalchemy/schema.py @@ -1572,27 +1572,6 @@ class MetaData(SchemaItem): return self._bind is not None - @util.deprecated('Deprecated. Use ``metadata.bind = `` or ' - '``metadata.bind = ``.') - def connect(self, bind, **kwargs): - """Bind this MetaData to an Engine. - - bind - A string, ``URL``, ``Engine`` or ``Connection`` instance. If a - string or ``URL``, will be passed to ``create_engine()`` along with - ``\**kwargs`` to produce the engine which to connect to. Otherwise - connects directly to the given ``Engine``. - - """ - global URL - if URL is None: - from sqlalchemy.engine.url import URL - if isinstance(bind, (basestring, URL)): - from sqlalchemy import create_engine - self._bind = create_engine(bind, **kwargs) - else: - self._bind = bind - def bind(self): """An Engine or Connection to which this MetaData is bound. @@ -1825,35 +1804,10 @@ class ThreadLocalMetaData(MetaData): def __init__(self): """Construct a ThreadLocalMetaData.""" - self.context = util.ThreadLocal() + self.context = util.threading.local() self.__engines = {} super(ThreadLocalMetaData, self).__init__() - @util.deprecated('Deprecated. Use ``metadata.bind = `` or ' - '``metadata.bind = ``.') - def connect(self, bind, **kwargs): - """Bind to an Engine in the caller's thread. - - bind - A string, ``URL``, ``Engine`` or ``Connection`` instance. If a - string or ``URL``, will be passed to ``create_engine()`` along with - ``\**kwargs`` to produce the engine which to connect to. Otherwise - connects directly to the given ``Engine``. - """ - - global URL - if URL is None: - from sqlalchemy.engine.url import URL - - if isinstance(bind, (basestring, URL)): - try: - engine = self.__engines[bind] - except KeyError: - from sqlalchemy import create_engine - engine = create_engine(bind, **kwargs) - bind = engine - self._bind_to(bind) - def bind(self): """The bound Engine or Connection for this thread. diff --git a/lib/sqlalchemy/util.py b/lib/sqlalchemy/util.py index 8c2847396e..adbe75e160 100644 --- a/lib/sqlalchemy/util.py +++ b/lib/sqlalchemy/util.py @@ -13,12 +13,9 @@ types = __import__('types') from sqlalchemy import exc try: - import thread as thread, threading as threading - from threading import local as ThreadLocal + import threading as threading except ImportError: - import dummy_thread as thread import dummy_threading as threading - from dummy_threading import local as ThreadLocal py3k = getattr(sys, 'py3kwarning', False) or sys.version_info >= (3, 0) diff --git a/test/dialect/sqlite.py b/test/dialect/sqlite.py index 23c0389550..29abfe0350 100644 --- a/test/dialect/sqlite.py +++ b/test/dialect/sqlite.py @@ -150,7 +150,7 @@ class TestDefaults(TestBase, AssertsExecutionResults): rt = Table('t_defaults', m2, autoload=True) expected = [c[1] for c in specs] for i, reflected in enumerate(rt.c): - self.assertEquals(reflected.server_default.arg.text, expected[i]) + self.assertEquals(reflected.server_default.arg, expected[i]) finally: m.drop_all() @@ -171,7 +171,7 @@ class TestDefaults(TestBase, AssertsExecutionResults): rt = Table('r_defaults', m, autoload=True) for i, reflected in enumerate(rt.c): - self.assertEquals(reflected.server_default.arg.text, expected[i]) + self.assertEquals(reflected.server_default.arg, expected[i]) finally: db.execute("DROP TABLE r_defaults") diff --git a/test/engine/bind.py b/test/engine/bind.py index 5b8605aada..e24881d594 100644 --- a/test/engine/bind.py +++ b/test/engine/bind.py @@ -118,7 +118,7 @@ class BindTest(testing.TestBase): table = Table('test_table', metadata, Column('foo', Integer)) - metadata.connect(bind) + metadata.bind = bind assert metadata.bind is table.bind is bind metadata.create_all() -- 2.47.3