"""Strategies for creating new instances of Engine types.
-These are semi-private implementation classes which
-provide the underlying behavior for the "strategy" keyword argument
-available on [sqlalchemy.engine#create_engine()].
-Current available options are ``plain``, ``threadlocal``, and
-``mock``.
-
-New strategies can be added via new ``EngineStrategy``
-classes.
-"""
+These are semi-private implementation classes which provide the
+underlying behavior for the "strategy" keyword argument available on
+[sqlalchemy.engine#create_engine()]. Current available options are
+``plain``, ``threadlocal``, and ``mock``.
+
+New strategies can be added via new ``EngineStrategy`` classes.
+"""
+from operator import attrgetter
from sqlalchemy.engine import base, threadlocal, url
from sqlalchemy import util, exc
from sqlalchemy import pool as poollib
+
strategies = {}
class EngineStrategy(object):
self.execute = execute
engine = property(lambda s: s)
- dialect = property(lambda s:s._dialect)
+ dialect = property(attrgetter('_dialect'))
+ name = property(lambda s: s._dialect.name)
def contextual_connect(self, **kwargs):
return self
'S S-T T-"s s"."t t"-b')
def test_filter(self):
cx = self.mock_engine()
- cx.name = 'mock'
tbl = Table('t', MetaData(), Column('id', Integer))
+ target = cx.name
assert DDL('')._should_execute('x', tbl, cx)
- assert DDL('', on='mock')._should_execute('x', tbl, cx)
+ assert DDL('', on=target)._should_execute('x', tbl, cx)
assert not DDL('', on='bogus')._should_execute('x', tbl, cx)
assert DDL('', on=lambda x,y,z: True)._should_execute('x', tbl, cx)
assert(DDL('', on=lambda x,y,z: z.engine.name != 'bogus').