# GNU MediaGoblin -- federated, autonomous media hosting
-# Copyright (C) 2011 MediaGoblin contributors. See AUTHORS.
+# 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
import sys
+from mediagoblin.db.sql.base import Session
+
def _simple_printer(string):
"""
if not MigrationData.__table__.exists(db.bind):
MigrationData.metadata.create_all(
db.bind, tables=[MigrationData.__table__])
+
+
+##########################
+# Random utility functions
+##########################
+
+
+def atomic_update(table, query_dict, update_values):
+ table.find(query_dict).update(update_values,
+ synchronize_session=False)
+ Session.commit()
if use_sql:
from mediagoblin.db.sql.fake import ObjectId, InvalidId, DESCENDING
+ from mediagoblin.db.sql.util import atomic_update
else:
from mediagoblin.db.mongo.util import \
ObjectId, InvalidId, DESCENDING, atomic_update