diff options
author | Christopher Allan Webber <cwebber@dustycloud.org> | 2011-07-13 23:14:42 -0500 |
---|---|---|
committer | Christopher Allan Webber <cwebber@dustycloud.org> | 2011-07-13 23:14:42 -0500 |
commit | c47c37ed953689e70441c4c143e4c06f1645be7d (patch) | |
tree | f63fed482a8e9c8dcd54cf0bd18d747f8516179b /mediagoblin/db | |
parent | 59051a23f01eb49ed6fe6975991730021ac169ac (diff) | |
parent | 6ae8b541f957b49ae86051814097e769d20f29af (diff) | |
download | mediagoblin-c47c37ed953689e70441c4c143e4c06f1645be7d.tar.lz mediagoblin-c47c37ed953689e70441c4c143e4c06f1645be7d.tar.xz mediagoblin-c47c37ed953689e70441c4c143e4c06f1645be7d.zip |
Merge branch 'master' into f411_new_migrations
Conflicts:
mediagoblin/db/open.py
Diffstat (limited to 'mediagoblin/db')
-rw-r--r-- | mediagoblin/db/indexes.py | 10 | ||||
-rw-r--r-- | mediagoblin/db/open.py | 3 | ||||
-rw-r--r-- | mediagoblin/db/util.py | 13 |
3 files changed, 18 insertions, 8 deletions
diff --git a/mediagoblin/db/indexes.py b/mediagoblin/db/indexes.py index d379a52b..a832e013 100644 --- a/mediagoblin/db/indexes.py +++ b/mediagoblin/db/indexes.py @@ -45,11 +45,13 @@ REQUIRED READING: To remove deprecated indexes ---------------------------- -Removing deprecated indexes is easier, just do: +Removing deprecated indexes is the same, just move the index into the +deprecated indexes mapping. -INACTIVE_INDEXES = { - 'collection_name': [ - 'deprecated_index_identifier1', 'deprecated_index_identifier2']} +DEPRECATED_INDEXES = { + 'collection_name': { + 'deprecated_index_identifier1': { + 'index': [index_foo_goes_here]}} ... etc. diff --git a/mediagoblin/db/open.py b/mediagoblin/db/open.py index cb040c29..e5fde6f9 100644 --- a/mediagoblin/db/open.py +++ b/mediagoblin/db/open.py @@ -38,6 +38,7 @@ def connect_database_from_config(app_config, use_pymongo=False): app_config.get('db_host'), port) return connection + def setup_connection_and_db_from_config(app_config, use_pymongo=False): """ Setup connection and database from config. @@ -45,7 +46,7 @@ def setup_connection_and_db_from_config(app_config, use_pymongo=False): Optionally use pymongo instead of mongokit. """ connection = connect_database_from_config(app_config, use_pymongo) - database_path = app_config.get('db_name', 'mediagoblin') + database_path = app_config['db_name'] db = connection[database_path] if not use_pymongo: diff --git a/mediagoblin/db/util.py b/mediagoblin/db/util.py index 0cdbd5c4..0f3220d2 100644 --- a/mediagoblin/db/util.py +++ b/mediagoblin/db/util.py @@ -86,18 +86,25 @@ def remove_deprecated_indexes(database, deprecated_indexes=DEPRECATED_INDEXES): Args: - database: pymongo or mongokit database instance. - deprecated_indexes: the indexes to deprecate in the pattern of: - {'collection': ['index_identifier1', 'index_identifier2']} + {'collection_name': { + 'identifier': { + 'index': [index_foo_goes_here], + 'unique': True}} + + (... although we really only need the 'identifier' here, as the + rest of the information isn't used in this case. But it's kept + around so we can remember what it was) Returns: A list of indexes removed in form ('collection', 'index_name') """ indexes_removed = [] - for collection_name, index_names in deprecated_indexes.iteritems(): + for collection_name, indexes in deprecated_indexes.iteritems(): collection = database[collection_name] collection_indexes = collection.index_information().keys() - for index_name in index_names: + for index_name, index_data in indexes.iteritems(): if index_name in collection_indexes: collection.drop_index(index_name) |