"""
Add token and expiration fields to help recover forgotten passwords
"""
- database['users'].update(
- {'fp_verification_key': {'$exists': False}},
- {'$set': {'fp_verification_key': None}},
- multi=True)
- database['users'].update(
- {'fp_token_expire': {'$exists': False}},
- {'$set': {'fp_token_expire': None}},
- multi=True)
+ add_table_field(database, 'users', 'fp_verification_key', None)
+ add_table_field(database, 'users', 'fp_token_expire', None)
+
+
+ @RegisterMigration(7)
+ def media_type_image_to_multimedia_type_image(database):
+ database['media_entries'].update(
+ {'media_type': 'image'},
+ {'$set': {'media_type': 'mediagoblin.media_types.image'}},
+ multi=True)
for entry in db.media_entries.find():
for name, path in entry['media_files'].items():
- _log.info('Exporting {0} - {1}'.format(
+ _log.info(u'Exporting {0} - {1}'.format(
entry['title'],
name))
-
- mc_file = media_cache.get_file(path, mode='wb')
- mc_file.write(
- mg_globals.public_store.get_file(path, mode='rb').read())
+ try:
+ mc_file = media_cache.get_file(path, mode='wb')
+ mc_file.write(
+ mg_globals.public_store.get_file(path, mode='rb').read())
+ except e:
+ _log.error('Failed: {0}'.format(e))
_log.info('...Media exported')
# Try to process, and handle expected errors.
try:
+ __import__(entry['media_type'])
process_image(entry)
except BaseProcessingFail, exc:
- mark_entry_failed(entry[u'_id'], exc)
+ mark_entry_failed(entry._id, exc)
return
+ except ImportError, exc:
+ mark_entry_failed(entry[u'_id'], exc)
entry['state'] = u'processed'
entry.save()
from werkzeug.utils import secure_filename
from mediagoblin.db.util import ObjectId
-from mediagoblin.util import (
- render_to_response, redirect, cleaned_markdown_conversion, \
- convert_to_tag_list_of_dicts)
-from mediagoblin.util import pass_to_ugettext as _
+from mediagoblin.tools.text import cleaned_markdown_conversion, convert_to_tag_list_of_dicts
+from mediagoblin.tools.translate import pass_to_ugettext as _
+from mediagoblin.tools.response import render_to_response, redirect
from mediagoblin.decorators import require_active_login
from mediagoblin.submit import forms as submit_forms, security
- from mediagoblin.process_media import process_media, mark_entry_failed
+ from mediagoblin.process_media import mark_entry_failed
from mediagoblin.messages import add_message, SUCCESS
+ from mediagoblin.media_types import get_media_type_and_manager
@require_active_login
# (... don't change entry after this point to avoid race
# conditions with changes to the document via processing code)
try:
- process_media.apply_async(
+ media_manager['processor'].apply_async(
- [unicode(entry['_id'])], {},
+ [unicode(entry._id)], {},
task_id=task_id)
except BaseException as exc:
# The purpose of this section is because when running in "lazy"
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
+ import sys
+
from mediagoblin import mg_globals
-from mediagoblin.util import render_to_response, Pagination
+from mediagoblin.tools.pagination import Pagination
+from mediagoblin.tools.response import render_to_response
from mediagoblin.db.util import DESCENDING
from mediagoblin.decorators import uses_pagination
+ from mediagoblin import media_types
+
+
@uses_pagination
def root_view(request, page):
cursor = request.db.MediaEntry.find(
def __unicode__(self):
return unicode(self.dir)
+
def __str__(self):
return str(self.dir)
+
def __repr__(self):
- return repr(self.dir)
+ try:
+ return str(self)
+ except AttributeError:
+ return 'None'
def joinpath(self, *args):
return os.path.join(self.dir, *args)
## their package managers.
# 'lxml',
],
+ requires=['gst'],
test_suite='nose.collector',
- entry_points = """\
+ entry_points="""\
[console_scripts]
gmg = mediagoblin.gmg_commands:main_cli
pybabel = mediagoblin.babel.messages.frontend:main