Merge branch 'master' into sqlmigrate
This commit is contained in:
commit
4d8be4fe0d
1
.gitignore
vendored
1
.gitignore
vendored
@ -15,6 +15,7 @@
|
|||||||
/user_dev/
|
/user_dev/
|
||||||
/paste_local.ini
|
/paste_local.ini
|
||||||
/mediagoblin_local.ini
|
/mediagoblin_local.ini
|
||||||
|
/mediagoblin.db
|
||||||
/server-log.txt
|
/server-log.txt
|
||||||
|
|
||||||
# Tests
|
# Tests
|
||||||
|
@ -5,6 +5,10 @@
|
|||||||
direct_remote_path = /mgoblin_static/
|
direct_remote_path = /mgoblin_static/
|
||||||
email_sender_address = "notice@mediagoblin.example.org"
|
email_sender_address = "notice@mediagoblin.example.org"
|
||||||
|
|
||||||
|
## Uncomment and change to your DB's appropiate setting.
|
||||||
|
## Default is a local sqlite db "mediagoblin.db".
|
||||||
|
# sql_engine = postgresql:///gmg
|
||||||
|
|
||||||
# set to false to enable sending notices
|
# set to false to enable sending notices
|
||||||
email_debug_mode = true
|
email_debug_mode = true
|
||||||
|
|
||||||
|
@ -9,6 +9,7 @@ media_types = string_list(default=list("mediagoblin.media_types.image"))
|
|||||||
db_host = string()
|
db_host = string()
|
||||||
db_name = string(default="mediagoblin")
|
db_name = string(default="mediagoblin")
|
||||||
db_port = integer()
|
db_port = integer()
|
||||||
|
sql_engine = string(default="sqlite:///%(here)s/mediagoblin.db")
|
||||||
|
|
||||||
# Where temporary files used in processing and etc are kept
|
# Where temporary files used in processing and etc are kept
|
||||||
workbench_path = string(default="%(here)s/user_dev/media/workbench")
|
workbench_path = string(default="%(here)s/user_dev/media/workbench")
|
||||||
|
@ -79,7 +79,7 @@ def convert_media_entries(mk_db):
|
|||||||
('title', 'slug', 'created',
|
('title', 'slug', 'created',
|
||||||
'description',
|
'description',
|
||||||
'media_type', 'state', 'license',
|
'media_type', 'state', 'license',
|
||||||
'fail_error',
|
'fail_error', 'fail_metadata',
|
||||||
'queued_task_id',))
|
'queued_task_id',))
|
||||||
copy_reference_attr(entry, new_entry, "uploader")
|
copy_reference_attr(entry, new_entry, "uploader")
|
||||||
|
|
||||||
@ -148,8 +148,7 @@ def convert_media_comments(mk_db):
|
|||||||
def main():
|
def main():
|
||||||
global_config, app_config = setup_global_and_app_config("mediagoblin.ini")
|
global_config, app_config = setup_global_and_app_config("mediagoblin.ini")
|
||||||
|
|
||||||
sql_conn, sql_db = sql_connect({'sql_engine': 'sqlite:///mediagoblin.db'})
|
sql_conn, sql_db = sql_connect(app_config)
|
||||||
|
|
||||||
mk_conn, mk_db = mongo_connect(app_config)
|
mk_conn, mk_db = mongo_connect(app_config)
|
||||||
|
|
||||||
Base.metadata.create_all(sql_db.engine)
|
Base.metadata.create_all(sql_db.engine)
|
||||||
|
@ -15,7 +15,8 @@
|
|||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
|
||||||
from sqlalchemy.types import TypeDecorator, Unicode
|
from sqlalchemy.types import TypeDecorator, Unicode, VARCHAR
|
||||||
|
import json
|
||||||
|
|
||||||
|
|
||||||
class PathTupleWithSlashes(TypeDecorator):
|
class PathTupleWithSlashes(TypeDecorator):
|
||||||
@ -35,3 +36,28 @@ class PathTupleWithSlashes(TypeDecorator):
|
|||||||
if value is not None:
|
if value is not None:
|
||||||
value = tuple(value.split('/'))
|
value = tuple(value.split('/'))
|
||||||
return value
|
return value
|
||||||
|
|
||||||
|
|
||||||
|
# The following class and only this one class is in very
|
||||||
|
# large parts based on example code from sqlalchemy.
|
||||||
|
#
|
||||||
|
# The original copyright notice and license follows:
|
||||||
|
# Copyright (C) 2005-2011 the SQLAlchemy authors and contributors <see AUTHORS file>
|
||||||
|
#
|
||||||
|
# This module is part of SQLAlchemy and is released under
|
||||||
|
# the MIT License: http://www.opensource.org/licenses/mit-license.php
|
||||||
|
#
|
||||||
|
class JSONEncoded(TypeDecorator):
|
||||||
|
"Represents an immutable structure as a json-encoded string."
|
||||||
|
|
||||||
|
impl = VARCHAR
|
||||||
|
|
||||||
|
def process_bind_param(self, value, dialect):
|
||||||
|
if value is not None:
|
||||||
|
value = json.dumps(value)
|
||||||
|
return value
|
||||||
|
|
||||||
|
def process_result_value(self, value, dialect):
|
||||||
|
if value is not None:
|
||||||
|
value = json.loads(value)
|
||||||
|
return value
|
||||||
|
@ -29,7 +29,7 @@ from sqlalchemy.orm.collections import attribute_mapped_collection
|
|||||||
from sqlalchemy.sql.expression import desc
|
from sqlalchemy.sql.expression import desc
|
||||||
from sqlalchemy.ext.associationproxy import association_proxy
|
from sqlalchemy.ext.associationproxy import association_proxy
|
||||||
|
|
||||||
from mediagoblin.db.sql.extratypes import PathTupleWithSlashes
|
from mediagoblin.db.sql.extratypes import PathTupleWithSlashes, JSONEncoded
|
||||||
from mediagoblin.db.sql.base import Base, DictReadAttrProxy
|
from mediagoblin.db.sql.base import Base, DictReadAttrProxy
|
||||||
from mediagoblin.db.mixin import UserMixin, MediaEntryMixin, MediaCommentMixin
|
from mediagoblin.db.mixin import UserMixin, MediaEntryMixin, MediaCommentMixin
|
||||||
|
|
||||||
@ -98,7 +98,7 @@ class MediaEntry(Base, MediaEntryMixin):
|
|||||||
license = Column(Unicode)
|
license = Column(Unicode)
|
||||||
|
|
||||||
fail_error = Column(Unicode)
|
fail_error = Column(Unicode)
|
||||||
fail_metadata = Column(UnicodeText)
|
fail_metadata = Column(JSONEncoded)
|
||||||
|
|
||||||
queued_media_file = Column(PathTupleWithSlashes)
|
queued_media_file = Column(PathTupleWithSlashes)
|
||||||
|
|
||||||
@ -214,10 +214,12 @@ class MediaTag(Base):
|
|||||||
creator=Tag.find_or_new
|
creator=Tag.find_or_new
|
||||||
)
|
)
|
||||||
|
|
||||||
def __init__(self, name, slug):
|
def __init__(self, name=None, slug=None):
|
||||||
Base.__init__(self)
|
Base.__init__(self)
|
||||||
self.name = name
|
if name is not None:
|
||||||
self.tag_helper = Tag.find_or_new(slug)
|
self.name = name
|
||||||
|
if slug is not None:
|
||||||
|
self.tag_helper = Tag.find_or_new(slug)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def dict_view(self):
|
def dict_view(self):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user