Skip to content
Myr

Merge branch '1.0-maintenance'

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by ThiefMaster · committed by ThiefMaster · parents b2ec6a3, 1a9caed · Browse files · 9 files+95 added−39 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

9 files+95 added−39 removed

  • tests:+39 added−10 removed
  • other:+56 added−29 removed

9 files+95 added−39 removed

modified:docs/installation.rst+4 added-1 removed
130 unmodified lines
131.. code-block:: sh132133 pip install Flask134135Flask is now installed. Check out the :doc:`/quickstart` or go to the136:doc:`Documentation Overview </index>`.137138Living on the edge139~~~~~~~~~~~~~~~~~~140141If you want to work with the latest Flask code before it's released, install or
37 unmodified lines
179180 \Python27\python.exe Downloads\get-pip.py181 \Python27\python.exe -m pip install virtualenv182180Now you can continue to :ref:`install-create-env`.183Now you can return above and :ref:`install-create-env`.184185.. _virtualenv: https://virtualenv.pypa.io/186.. _get-pip.py: https://bootstrap.pypa.io/get-pip.py
modified:flask/cli.py+16 added-11 removed
338 unmodified lines
339 :class:`FlaskGroup` but you can also manually create it and pass it340 onwards as click object.341 """342343 def __init__(self, app_import_path=None, create_app=None):343 def __init__(self, app_import_path=None, create_app=None,344 set_debug_flag=True):345 #: Optionally the import path for the Flask application.346 self.app_import_path = app_import_path or os.environ.get('FLASK_APP')347 #: Optionally a function that is passed the script info to create348 #: the instance of the application.349 self.create_app = create_app350 #: A dictionary with arbitrary data that can be associated with351 #: this script info.352 self.data = {}353 self.set_debug_flag = set_debug_flag354 self._loaded_app = None355356 def load_app(self):357 """Loads the Flask app (if not yet loaded) and returns it. Calling
29 unmodified lines
387 'the "FLASK_APP" environment variable, and a "wsgi.py" or '388 '"app.py" module was not found in the current directory.'389 )390391 if self.set_debug_flag:392 # Update the app's debug flag through the descriptor so that393 # other values repopulate as well.389 debug = get_debug_flag()394 app.debug = get_debug_flag()395391 # Update the app's debug flag through the descriptor so that other392 # values repopulate as well.393 if debug is not None:394 app.debug = debug395396 self._loaded_app = app397 return app398399
58 unmodified lines
458 returns the loaded app.459 :param load_dotenv: Load the nearest :file:`.env` and :file:`.flaskenv`460 files to set environment variables. Will also change the working461 directory to the directory containing the first file found.462 :param set_debug_flag: Set the app's debug flag based on the active463 environment464465 .. versionchanged:: 1.0466 If installed, python-dotenv will be used to load environment variables467 from :file:`.env` and :file:`.flaskenv` files.468 """469470 def __init__(self, add_default_commands=True, create_app=None,469 add_version_option=True, load_dotenv=True, **extra):471 add_version_option=True, load_dotenv=True,472 set_debug_flag=True, **extra):473 params = list(extra.pop('params', None) or ())474475 if add_version_option:476 params.append(version_option)477478 AppGroup.__init__(self, params=params, **extra)479 self.create_app = create_app480 self.load_dotenv = load_dotenv481 self.set_debug_flag = set_debug_flag482483 if add_default_commands:484 self.add_command(run_command)485 self.add_command(shell_command)
67 unmodified lines
553554 obj = kwargs.get('obj')555556 if obj is None:553 obj = ScriptInfo(create_app=self.create_app)557 obj = ScriptInfo(create_app=self.create_app,558 set_debug_flag=self.set_debug_flag)559560 kwargs['obj'] = obj561 kwargs.setdefault('auto_envvar_prefix', 'FLASK')562 return super(FlaskGroup, self).main(*args, **kwargs)
111 unmodified lines
674 return value675676 obj = import_string(value, silent=True)677673 if sys.version_info < (2, 7):678 if sys.version_info < (2, 7, 9):679 if obj:680 return obj681 else:682 if isinstance(obj, ssl.SSLContext):
8 unmodified lines
691 """692 cert = ctx.params.get('cert')693 is_adhoc = cert == 'adhoc'694690 if sys.version_info < (2, 7):695 if sys.version_info < (2, 7, 9):696 is_context = cert and not isinstance(cert, (text_type, bytes))697 else:698 is_context = isinstance(cert, ssl.SSLContext)699
204 unmodified lines
modified:flask/helpers.py+6 added-2 removed
504 unmodified lines
505 UTF-8 filenames, as specified in `RFC 2231`_, are supported.506507 .. _RFC 2231: https://tools.ietf.org/html/rfc2231#section-4508509 .. versionchanged:: 1.0.3510 Filenames are encoded with ASCII instead of Latin-1 for broader511 compatibility with WSGI servers.512513 :param filename_or_fp: the filename of the file to send.514 This is relative to the :attr:`~Flask.root_path`515 if a relative path is specified.516 Alternatively a file object might be provided in
50 unmodified lines
567 raise TypeError('filename unavailable, required for '568 'sending as attachment')569570 try:567 attachment_filename = attachment_filename.encode('latin-1')571 attachment_filename = attachment_filename.encode('ascii')572 except UnicodeEncodeError:573 filenames = {574 'filename': unicodedata.normalize(571 'NFKD', attachment_filename).encode('latin-1', 'ignore'),575 'NFKD', attachment_filename).encode('ascii', 'ignore'),576 'filename*': "UTF-8''%s" % url_quote(attachment_filename),577 }578 else:579 filenames = {'filename': attachment_filename}
469 unmodified lines
modified:tests/test_cli.py+24 added-2 removed
354 unmodified lines
355 assert result.exit_code == 0356 assert result.output == 'flaskgroup\n'357358359@pytest.mark.parametrize('set_debug_flag', (True, False))360def test_flaskgroup_debug(runner, set_debug_flag):361 """Test FlaskGroup debug flag behavior."""362363 def create_app(info):364 app = Flask("flaskgroup")365 app.debug = True366 return app367368 @click.group(cls=FlaskGroup, create_app=create_app, set_debug_flag=set_debug_flag)369 def cli(**params):370 pass371372 @cli.command()373 def test():374 click.echo(str(current_app.debug))375376 result = runner.invoke(cli, ['test'])377 assert result.exit_code == 0378 assert result.output == '%s\n' % str(not set_debug_flag)379380381def test_print_exceptions(runner):382 """Print the stacktrace if the CLI."""383384 def create_app(info):
173 unmodified lines
558 with pytest.raises(click.BadParameter):559 run_command.make_context('run', ['--cert', 'not_here'])560561 # not an SSLContext540 if sys.version_info >= (2, 7):562 if sys.version_info >= (2, 7, 9):563 with pytest.raises(click.BadParameter):564 run_command.make_context('run', ['--cert', 'flask'])565566 # SSLContext545 if sys.version_info < (2, 7):567 if sys.version_info < (2, 7, 9):568 ssl_context = object()569 else:570 ssl_context = ssl.SSLContext(ssl.PROTOCOL_SSLv23)571
8 unmodified lines
modified:tests/test_helpers.py+15 added-8 removed
636 unmodified lines
637 assert value == 'attachment'638 assert options['filename'] == 'index.txt'639 rv.close()640641 def test_attachment_with_utf8_filename(self, app, req_ctx):642 rv = flask.send_file('static/index.html', as_attachment=True, attachment_filename=u'Ñandú/pingüino.txt')643 content_disposition = set(rv.headers['Content-Disposition'].split('; '))644 assert content_disposition == set((645 'attachment',646 'filename="Nandu/pinguino.txt"',647 "filename*=UTF-8''%C3%91and%C3%BA%EF%BC%8Fping%C3%BCino.txt"648 ))641 @pytest.mark.usefixtures('req_ctx')642 @pytest.mark.parametrize(('filename', 'ascii', 'utf8'), (643 ('index.html', 'index.html', False),644 (u'Ñandú/pingüino.txt', '"Nandu/pinguino.txt"',645 '%C3%91and%C3%BA%EF%BC%8Fping%C3%BCino.txt'),646 (u'Vögel.txt', 'Vogel.txt', 'V%C3%B6gel.txt'),647 ))648 def test_attachment_filename_encoding(self, filename, ascii, utf8):649 rv = flask.send_file('static/index.html', as_attachment=True, attachment_filename=filename)650 rv.close()651 content_disposition = rv.headers['Content-Disposition']652 assert 'filename=%s' % ascii in content_disposition653 if utf8:654 assert "filename*=UTF-8''" + utf8 in content_disposition655 else:656 assert "filename*=UTF-8''" not in content_disposition657658 def test_static_file(self, app, req_ctx):659 # default cache timeout is 12 hours660
294 unmodified lines
modified:.appveyor.yml+7 added-4 removed
modified:.travis.yml+13 added-10 removed
modified:CHANGES.rst+9 added
13 unmodified lines
14-------------1516Unreleased1718- :func:`send_file` encodes filenames as ASCII instead of Latin-119 (ISO-8859-1). This fixes compatibility with Gunicorn, which is20 stricter about header encodings than PEP 3333. (`#2766`_)21- Allow custom CLIs using ``FlaskGroup`` to set the debug flag without22 it always being overwritten based on environment variables. (`#2765`_)2324.. _#2766: https://github.com/pallets/flask/issues/276625.. _#2765: https://github.com/pallets/flask/pull/2765262728Version 1.0.229-------------3031Released on May 2nd 2018
909 unmodified lines
modified:tox.ini+1 added-1 removed
58 unmodified lines
59 coverage report60 coverage html6162[testenv:codecov]63passenv = CI TRAVIS TRAVIS_*63passenv = CI TRAVIS TRAVIS_* APPVEYOR APPVEYOR_*64deps = codecov65skip_install = true66commands =67 coverage combine
2 unmodified lines