diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2006-03-01 21:20:59 +0000 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2006-03-01 21:20:59 +0000 |
| commit | fd8d4a45ea1c2087ed3c4a86bf5f889b194fdb48 (patch) | |
| tree | 5afc754c8c249c774f773476dd1d9518ad4b41e7 /lib/sqlalchemy/ext | |
| parent | fd8567037269ac937a6b079c6e00022abfc51149 (diff) | |
| download | sqlalchemy-fd8d4a45ea1c2087ed3c4a86bf5f889b194fdb48.tar.gz | |
made SchemaEngine more prominent as the base of Table association
BaseProxyEngine descends from SchemaEngine
fixes to sqlite/postgres reflection to use the correct engine for table lookups
Table engine can be none which will default to schema.default_engine (although its
still positional for now, so still needs to be explicit to make room for Columns)
__init__ sets default_engine to be a blank ProxyEngine
fixes to test suite to allow --db proxy.<dbname> to really test proxyengine
Diffstat (limited to 'lib/sqlalchemy/ext')
| -rw-r--r-- | lib/sqlalchemy/ext/proxy.py | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/lib/sqlalchemy/ext/proxy.py b/lib/sqlalchemy/ext/proxy.py index 783ea969e..b8351d38f 100644 --- a/lib/sqlalchemy/ext/proxy.py +++ b/lib/sqlalchemy/ext/proxy.py @@ -6,16 +6,14 @@ except ImportError: from sqlalchemy import sql from sqlalchemy.engine import create_engine from sqlalchemy.types import TypeEngine - +import sqlalchemy.schema as schema import thread, weakref -class BaseProxyEngine(object): +class BaseProxyEngine(schema.SchemaEngine): ''' Basis for all proxy engines ''' - def __init__(self): - self.tables = {} - + def get_engine(self): raise NotImplementedError @@ -24,6 +22,9 @@ class BaseProxyEngine(object): engine = property(get_engine, set_engine) + def reflecttable(self, table): + return self.get_engine().reflecttable(table) + def hash_key(self): return "%s(%s)" % (self.__class__.__name__, id(self)) @@ -83,16 +84,20 @@ class ProxyEngine(BaseProxyEngine): classes for TypeEngine. """ - def __init__(self): + def __init__(self, **kwargs): BaseProxyEngine.__init__(self) # create the local storage for uri->engine map and current engine self.storage = local() self.storage.connection = {} self.storage.engine = None + self.kwargs = kwargs def connect(self, uri, opts=None, **kwargs): """Establish connection to a real engine. """ + kw = self.kwargs.copy() + kw.update(kwargs) + kwargs = kw key = "%s(%s,%s)" % (uri, repr(opts), repr(kwargs)) try: map = self.storage.connection |
