diff options
author | Elrond <elrond+mediagoblin.org@samba-tng.org> | 2011-12-31 23:01:34 +0100 |
---|---|---|
committer | Elrond <elrond+mediagoblin.org@samba-tng.org> | 2012-01-11 12:19:03 +0100 |
commit | 02db7e0a83fc06eaa8e96888f6c9e4fb44e7cbe2 (patch) | |
tree | 04bc7ee1b47416771f37abb759d9895b995744dc /mediagoblin/db/sql/convert.py | |
parent | 0ab21f981a8a170f5bf4e83f7d56d3ed8fdae467 (diff) | |
download | mediagoblin-02db7e0a83fc06eaa8e96888f6c9e4fb44e7cbe2.tar.lz mediagoblin-02db7e0a83fc06eaa8e96888f6c9e4fb44e7cbe2.tar.xz mediagoblin-02db7e0a83fc06eaa8e96888f6c9e4fb44e7cbe2.zip |
Add MediaFile table and related infrastructure.
- This adds a new SQL table field type for path tuples.
They're stored as '/' separated unicode strings.
- Uses it to implement a MediaFile table.
- Add relationship and proxy fields on MediaEntry to give a
nice media_files "view" there.
- Let the converter fill the MediaFile.
Diffstat (limited to 'mediagoblin/db/sql/convert.py')
-rw-r--r-- | mediagoblin/db/sql/convert.py | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/mediagoblin/db/sql/convert.py b/mediagoblin/db/sql/convert.py index 6698b767..88614fd4 100644 --- a/mediagoblin/db/sql/convert.py +++ b/mediagoblin/db/sql/convert.py @@ -2,7 +2,7 @@ from mediagoblin.init import setup_global_and_app_config, setup_database from mediagoblin.db.mongo.util import ObjectId from mediagoblin.db.sql.models import (Base, User, MediaEntry, MediaComment, - Tag, MediaTag) + Tag, MediaTag, MediaFile) from mediagoblin.db.sql.open import setup_connection_and_db_from_config as \ sql_connect from mediagoblin.db.mongo.open import setup_connection_and_db_from_config as \ @@ -70,6 +70,11 @@ def convert_media_entries(mk_db): session.flush() add_obj_ids(entry, new_entry) + for key, value in entry.media_files.iteritems(): + new_file = MediaFile(name=key, file_path=value) + new_file.media_entry = new_entry.id + Session.add(new_file) + session.commit() session.close() |