Use six.text_type instead of unicode().
I will be switch to use ``from __future__ import unicode_literals`` later.
This commit is contained in:
@@ -18,6 +18,8 @@ import logging
|
||||
import uuid
|
||||
from os.path import splitext
|
||||
|
||||
import six
|
||||
|
||||
from werkzeug.utils import secure_filename
|
||||
from werkzeug.datastructures import FileStorage
|
||||
|
||||
@@ -127,7 +129,7 @@ def submit_media(mg_app, user, submitted_file, filename,
|
||||
|
||||
# If the filename contains non ascii generate a unique name
|
||||
if not all(ord(c) < 128 for c in filename):
|
||||
filename = unicode(uuid.uuid4()) + splitext(filename)[-1]
|
||||
filename = six.text_type(uuid.uuid4()) + splitext(filename)[-1]
|
||||
|
||||
# Sniff the submitted media to determine which
|
||||
# media plugin should handle processing
|
||||
@@ -136,7 +138,7 @@ def submit_media(mg_app, user, submitted_file, filename,
|
||||
# create entry and save in database
|
||||
entry = new_upload_entry(user)
|
||||
entry.media_type = media_type
|
||||
entry.title = (title or unicode(splitext(filename)[0]))
|
||||
entry.title = (title or six.text_type(splitext(filename)[0]))
|
||||
|
||||
entry.description = description or u""
|
||||
|
||||
@@ -210,7 +212,7 @@ def prepare_queue_task(app, entry, filename):
|
||||
# (If we got it off the task's auto-generation, there'd be
|
||||
# a risk of a race condition when we'd save after sending
|
||||
# off the task)
|
||||
task_id = unicode(uuid.uuid4())
|
||||
task_id = six.text_type(uuid.uuid4())
|
||||
entry.queued_task_id = task_id
|
||||
|
||||
# Now store generate the queueing related filename
|
||||
|
||||
@@ -14,6 +14,8 @@
|
||||
# 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 six
|
||||
|
||||
from mediagoblin import messages
|
||||
import mediagoblin.mg_globals as mg_globals
|
||||
|
||||
@@ -59,9 +61,9 @@ def submit_start(request):
|
||||
mg_app=request.app, user=request.user,
|
||||
submitted_file=request.files['file'],
|
||||
filename=request.files['file'].filename,
|
||||
title=unicode(submit_form.title.data),
|
||||
description=unicode(submit_form.description.data),
|
||||
license=unicode(submit_form.license.data) or None,
|
||||
title=six.text_type(submit_form.title.data),
|
||||
description=six.text_type(submit_form.description.data),
|
||||
license=six.text_type(submit_form.license.data) or None,
|
||||
tags_string=submit_form.tags.data,
|
||||
upload_limit=upload_limit, max_file_size=max_file_size,
|
||||
urlgen=request.urlgen)
|
||||
@@ -117,8 +119,8 @@ def add_collection(request, media=None):
|
||||
if request.method == 'POST' and submit_form.validate():
|
||||
collection = request.db.Collection()
|
||||
|
||||
collection.title = unicode(submit_form.title.data)
|
||||
collection.description = unicode(submit_form.description.data)
|
||||
collection.title = six.text_type(submit_form.title.data)
|
||||
collection.description = six.text_type(submit_form.description.data)
|
||||
collection.creator = request.user.id
|
||||
collection.generate_slug()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user