From 94048a282ed8085df4f6f08931dd1c3804236b76 Mon Sep 17 00:00:00 2001 From: minimumserious Date: Thu, 13 Jun 2013 09:28:42 +0200 Subject: Cleaning --- factory/alchemy.py | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/factory/alchemy.py b/factory/alchemy.py index 87a17fa..8ede97f 100644 --- a/factory/alchemy.py +++ b/factory/alchemy.py @@ -18,15 +18,8 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. - from . import base -try: - from sqlalchemy.sql.functions import max -except ImportError: - def max(): - raise ImportError('sqlalchemy is not found!') - class SQLAlchemyModelFactory(base.Factory): """Factory for SQLAlchemy models. """ @@ -36,6 +29,7 @@ class SQLAlchemyModelFactory(base.Factory): @classmethod def _setup_next_sequence(cls, *args, **kwargs): """Compute the next available PK, based on the 'pk' database field.""" + from sqlalchemy.sql.functions import max session = cls.FACTORY_SESSION pk = cls.FACTORY_FOR.__table__.primary_key.columns.values()[0].key max_pk = session.query(max(getattr(cls.FACTORY_FOR, pk))).one() -- cgit v1.2.3