Merge pull request #454 from coreos-inc/urlfor

Remove uses of _external for url_for
This commit is contained in:
josephschorr 2015-09-14 15:54:42 -04:00
commit 6d8752bdb5

View file

@ -1,11 +1,13 @@
import os import os
import logging import logging
import magic import magic
import urlparse
from uuid import uuid4 from uuid import uuid4
from flask import url_for, request, send_file, make_response, abort from flask import url_for, request, send_file, make_response, abort
from flask.views import View from flask.views import View
from _pyio import BufferedReader from _pyio import BufferedReader
from util import get_app_url
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
@ -77,7 +79,9 @@ class DelegateUserfiles(object):
if url is None: if url is None:
with self._app.app_context() as ctx: with self._app.app_context() as ctx:
ctx.url_adapter = self._build_url_adapter() ctx.url_adapter = self._build_url_adapter()
return (url_for(self._handler_name, file_id=file_id, _external=True), file_id) file_relative_url = url_for(self._handler_name, file_id=file_id)
file_url = urlparse.urljoin(get_app_url(self._app.config), file_relative_url)
return (file_url, file_id)
return (url, file_id) return (url, file_id)
@ -97,7 +101,8 @@ class DelegateUserfiles(object):
if url is None: if url is None:
with self._app.app_context() as ctx: with self._app.app_context() as ctx:
ctx.url_adapter = self._build_url_adapter() ctx.url_adapter = self._build_url_adapter()
return url_for(self._handler_name, file_id=file_id, _external=True) file_relative_url = url_for(self._handler_name, file_id=file_id)
return urlparse.urljoin(get_app_url(self._app.config), file_relative_url)
return url return url