From 39dc3bf8db4a0a21220560a259574da4f2c1e12a Mon Sep 17 00:00:00 2001 From: Sebastian Spaeth Date: Mon, 7 Jan 2013 13:03:51 +0100 Subject: [PATCH] Mv db.sql.base to db.base This concludes the db.sql.* -> db.* move. Our db abstraction layer is sqlalchemy, so there is no need to a separate db.sql.* hierarchy. All tests have been run for each of the commit series to make sure everything works at every step. --- mediagoblin/db/{sql => }/base.py | 0 mediagoblin/db/models.py | 3 +-- mediagoblin/db/models_v0.py | 3 +-- mediagoblin/db/open.py | 2 +- mediagoblin/db/sql/__init__.py | 15 --------------- mediagoblin/db/util.py | 2 +- mediagoblin/media_types/ascii/models.py | 2 +- mediagoblin/media_types/audio/models.py | 2 +- mediagoblin/media_types/image/models.py | 2 +- mediagoblin/media_types/video/models.py | 2 +- mediagoblin/plugins/oauth/models.py | 2 +- mediagoblin/tests/test_sql_migrations.py | 2 +- mediagoblin/tests/tools.py | 3 +-- 13 files changed, 11 insertions(+), 29 deletions(-) rename mediagoblin/db/{sql => }/base.py (100%) delete mode 100644 mediagoblin/db/sql/__init__.py diff --git a/mediagoblin/db/sql/base.py b/mediagoblin/db/base.py similarity index 100% rename from mediagoblin/db/sql/base.py rename to mediagoblin/db/base.py diff --git a/mediagoblin/db/models.py b/mediagoblin/db/models.py index 54f9abbc..ea915ae5 100644 --- a/mediagoblin/db/models.py +++ b/mediagoblin/db/models.py @@ -32,9 +32,8 @@ from sqlalchemy.ext.associationproxy import association_proxy from sqlalchemy.util import memoized_property from mediagoblin.db.extratypes import PathTupleWithSlashes, JSONEncoded -from mediagoblin.db.sql.base import Base, DictReadAttrProxy +from mediagoblin.db.base import Base, DictReadAttrProxy, Session from mediagoblin.db.mixin import UserMixin, MediaEntryMixin, MediaCommentMixin, CollectionMixin, CollectionItemMixin -from mediagoblin.db.sql.base import Session # It's actually kind of annoying how sqlalchemy-migrate does this, if # I understand it right, but whatever. Anyway, don't remove this :P diff --git a/mediagoblin/db/models_v0.py b/mediagoblin/db/models_v0.py index 742c4652..ec51a1f5 100644 --- a/mediagoblin/db/models_v0.py +++ b/mediagoblin/db/models_v0.py @@ -32,8 +32,7 @@ from sqlalchemy.ext.associationproxy import association_proxy from sqlalchemy.util import memoized_property from mediagoblin.db.extratypes import PathTupleWithSlashes, JSONEncoded -from mediagoblin.db.sql.base import GMGTableBase -from mediagoblin.db.sql.base import Session +from mediagoblin.db.base import GMGTableBase, Session Base_v0 = declarative_base(cls=GMGTableBase) diff --git a/mediagoblin/db/open.py b/mediagoblin/db/open.py index 11b2dc97..d976acd8 100644 --- a/mediagoblin/db/open.py +++ b/mediagoblin/db/open.py @@ -18,7 +18,7 @@ from sqlalchemy import create_engine import logging -from mediagoblin.db.sql.base import Base, Session +from mediagoblin.db.base import Base, Session from mediagoblin import mg_globals _log = logging.getLogger(__name__) diff --git a/mediagoblin/db/sql/__init__.py b/mediagoblin/db/sql/__init__.py deleted file mode 100644 index 621845ba..00000000 --- a/mediagoblin/db/sql/__init__.py +++ /dev/null @@ -1,15 +0,0 @@ -# GNU MediaGoblin -- federated, autonomous media hosting -# Copyright (C) 2011, 2012 MediaGoblin contributors. See AUTHORS. -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . diff --git a/mediagoblin/db/util.py b/mediagoblin/db/util.py index 32dd0884..2017cfc0 100644 --- a/mediagoblin/db/util.py +++ b/mediagoblin/db/util.py @@ -14,7 +14,7 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . import sys -from mediagoblin.db.sql.base import Session +from mediagoblin.db.base import Session from mediagoblin.db.models import MediaEntry, Tag, MediaTag, Collection from mediagoblin.tools.common import simple_printer diff --git a/mediagoblin/media_types/ascii/models.py b/mediagoblin/media_types/ascii/models.py index 60420fdd..3416993c 100644 --- a/mediagoblin/media_types/ascii/models.py +++ b/mediagoblin/media_types/ascii/models.py @@ -15,7 +15,7 @@ # along with this program. If not, see . -from mediagoblin.db.sql.base import Base +from mediagoblin.db.base import Base from sqlalchemy import ( Column, Integer, ForeignKey) diff --git a/mediagoblin/media_types/audio/models.py b/mediagoblin/media_types/audio/models.py index 08a90f54..368ab1eb 100644 --- a/mediagoblin/media_types/audio/models.py +++ b/mediagoblin/media_types/audio/models.py @@ -15,7 +15,7 @@ # along with this program. If not, see . -from mediagoblin.db.sql.base import Base +from mediagoblin.db.base import Base from sqlalchemy import ( Column, Integer, ForeignKey) diff --git a/mediagoblin/media_types/image/models.py b/mediagoblin/media_types/image/models.py index 0ac9caab..63d80aa8 100644 --- a/mediagoblin/media_types/image/models.py +++ b/mediagoblin/media_types/image/models.py @@ -15,7 +15,7 @@ # along with this program. If not, see . -from mediagoblin.db.sql.base import Base +from mediagoblin.db.base import Base from sqlalchemy import ( Column, Integer, Float, ForeignKey) diff --git a/mediagoblin/media_types/video/models.py b/mediagoblin/media_types/video/models.py index 4e02cb9a..645ef4d3 100644 --- a/mediagoblin/media_types/video/models.py +++ b/mediagoblin/media_types/video/models.py @@ -15,7 +15,7 @@ # along with this program. If not, see . -from mediagoblin.db.sql.base import Base +from mediagoblin.db.base import Base from sqlalchemy import ( Column, Integer, SmallInteger, ForeignKey) diff --git a/mediagoblin/plugins/oauth/models.py b/mediagoblin/plugins/oauth/models.py index f52a8ce9..695dad31 100644 --- a/mediagoblin/plugins/oauth/models.py +++ b/mediagoblin/plugins/oauth/models.py @@ -19,7 +19,7 @@ import bcrypt from datetime import datetime, timedelta -from mediagoblin.db.sql.base import Base +from mediagoblin.db.base import Base from mediagoblin.db.models import User from sqlalchemy import ( diff --git a/mediagoblin/tests/test_sql_migrations.py b/mediagoblin/tests/test_sql_migrations.py index 0e7102bc..26979bdf 100644 --- a/mediagoblin/tests/test_sql_migrations.py +++ b/mediagoblin/tests/test_sql_migrations.py @@ -25,7 +25,7 @@ from sqlalchemy.ext.declarative import declarative_base from sqlalchemy.sql import select, insert from migrate import changeset -from mediagoblin.db.sql.base import GMGTableBase +from mediagoblin.db.base import GMGTableBase from mediagoblin.db.util import MigrationManager, RegisterMigration from mediagoblin.tools.common import CollectingPrinter diff --git a/mediagoblin/tests/tools.py b/mediagoblin/tests/tools.py index 0e923aee..31afb08b 100644 --- a/mediagoblin/tests/tools.py +++ b/mediagoblin/tests/tools.py @@ -28,7 +28,7 @@ from mediagoblin import mg_globals from mediagoblin.tools import testing from mediagoblin.init.config import read_mediagoblin_config from mediagoblin.db.open import setup_connection_and_db_from_config -from mediagoblin.db.sql.base import Session +from mediagoblin.db.base import Session from mediagoblin.meddleware import BaseMeddleware from mediagoblin.auth.lib import bcrypt_gen_password_hash from mediagoblin.gmg_commands.dbupdate import run_dbupdate @@ -219,7 +219,6 @@ def fixture_add_user(username=u'chris', password='toast', test_user = mg_globals.database.User.find_one({'username': username}) # ... and detach from session: - from mediagoblin.db.sql.base import Session Session.expunge(test_user) return test_user -- 2.25.1