Commit Graph

646 Commits

Author SHA1 Message Date
pgjones 99afbb277d Fix blueprint nested url_prefix
This ensures that the url_prefix is correctly applied, no matter if
set during the registration override or when constructing the
blueprint.
2021-05-21 15:04:18 +01:00
Danny Sepler 1b5f21e015
Add pathlib in cli tests 2021-05-17 08:46:36 -07:00
pgjones 6fbdeb80c7 Fix nested blueprint url_prefix
This fixes the case where the blueprint is registered with a
url_prefix but any child blueprints have no prefixes.
2021-05-17 15:47:25 +01:00
David Lord a7b02b3a07
converters have access to session 2021-05-14 08:11:09 -07:00
David Lord 8648750997
Merge branch '1.1.x' into 2.0.x 2021-05-13 18:47:06 -07:00
brettlangdon 3ace642ef3
Use compat fspath instead of os.fspath
When 7ba35c4 was cherry-picked it introduced the
usage of os.fspath which is not supported on
Python <3.6
2021-05-13 18:17:00 -07:00
Grey Li e93704fbfd
fix url_prefix argument when nesting blueprints 2021-05-13 15:02:13 -07:00
David Lord 7c5261407d
blueprint name may not contain a dot 2021-05-13 14:31:50 -07:00
pgjones 2889da67cb
Remove the async helper method
It is better to encourage users to utilise the app ensure_sync method
(or the newely added async_to_sync method) so that any extensions that
alter these methods take affect throughout the users code.

With the helper method users code fix parts of their code to the
asgiref async_to_sync ignoring any extension changes.
2021-05-03 06:18:41 -07:00
pgjones 7f87f3dd93
Simplify the async handling code
Firstly `run_sync` was a misleading name as it didn't run anything,
instead I think `async_to_sync` is much clearer as it converts a
coroutine function to a function. (Name stolen from asgiref).

Secondly trying to run the ensure_sync during registration made the
code more complex and brittle, e.g. the _flask_async_wrapper
usage. This was done to pay any setup costs during registration rather
than runtime, however this only saved a iscoroutne check. It allows
the weirdness of the Blueprint and Scaffold ensure_sync methods to be
removed.

Switching to runtime ensure_sync usage provides a method for
extensions to also support async, as now documented.
2021-05-03 06:15:39 -07:00
Adrian Moennich 26a6cc0f94 Allow using Click 7 with a DeprecationWarning
As long as popular libraries (e.g. Celery) require click 7, depending
on Click 8 in Flask makes it hard to test the latest version (and its
other dependencies) in existing applications.
2021-04-27 16:45:06 +02:00
pgjones 5c6a0f0c12 Fix wrapped view function comparison
Wrapped functions are not comparable, see
https://bugs.python.org/issue3564, therefore a marker is used to note
when the function has been sync wrapped to allow comparison with the
wrapped function instead.

This ensures that multiple route decorators work without raising
exceptions i.e.,

    @app.route("/")
    @app.route("/a")
    async def index():
        ...

works.
2021-04-16 12:34:51 +01:00
pgjones f92e820b4b
Nested blueprints
This allows blueprints to be nested within blueprints via a new
Blueprint.register_blueprint method. This should provide a use case
that has been desired for the past ~10 years.

This works by setting the endpoint name to be the blueprint names,
from parent to child delimeted by "." and then iterating over the
blueprint names in reverse order in the app (from most specific to
most general). This means that the expectation of nesting a blueprint
within a nested blueprint is met.
2021-04-14 09:25:42 -07:00
David Lord 61fbae8664
skip async tests if asgiref isn't installed 2021-04-06 15:33:06 -07:00
pgjones 00f5a3e55c
Alter ensure_sync implementation to support extensions
This allows extensions to override the Flask.ensure_sync method and
have the change apply to blueprints as well. Without this change it is
possible for differing blueprints to have differing ensure_sync
approaches depending on the extension used - which would likely result
in event-loop blocking issues.

This also allows blueprints to have a custom ensure_sync, although
this is a by product rather than an expected use case.
2021-04-06 15:33:06 -07:00
pgjones c6c6408c3f
Raise a runtime error if run_async is called without real ContextVars
Werkzeug offers a ContextVar replacement for Python < 3.7, however it
doesn't work across asyncio tasks, hence it makes sense to error out
rather than find there are odd bugs.

Note the docs build requires the latest (dev) Werkzeug due to this
change (to import ContextVar from werkzeug.local).
2021-04-06 09:35:10 -07:00
pgjones 6979265fa6
Add `async` support
This allows for async functions to be passed to the Flask class
instance, for example as a view function,

    @app.route("/")
    async def index():
        return "Async hello"

this comes with a cost though of poorer performance than using the
sync equivalent.

asgiref is the standard way to run async code within a sync context,
and is used in Django making it a safe and sane choice for this.
2021-04-06 09:35:10 -07:00
Grey Li 33145c3699 Set default encoding to UTF-8 for load_dotenv 2021-03-10 21:40:29 +08:00
pgjones 705e52684a
Add syntatic sugar for route registration
This takes a popular API whereby instead of passing the HTTP method as
an argument to route it is instead used as the method name i.e.

    @app.route("/", methods=["POST"])

is now writeable as,

    @app.post("/")

This is simply syntatic sugar, it doesn't do anything else, but makes
it slightly easier for users.

I've included all the methods that are relevant and aren't auto
generated i.e. not connect, head, options, and trace.
2021-03-08 08:55:14 -08:00
Grey Li 49b7341a49
update json.dumps for http_date changes 2021-02-25 09:45:55 -08:00
David Lord 0ee1b0b5d9
remove test relying on Werkzeug Local internals 2021-02-08 18:04:02 -08:00
David Lord b473e7c97c
use Jinja's tojson filter 2021-02-01 22:48:09 -08:00
Matthew Preble 01621485fd
Ensure session_interface.open_session is called after URL matching (#3776) 2021-02-01 20:41:17 -08:00
Grey Li eb41e7e417 Silence pytest warnings for exception propagation test 2021-01-03 13:57:45 +08:00
David Lord dc11cdb4a4
move send_file and send_from_directory to Werkzeug
The implementations were moved to Werkzeug, Flask's functions become
wrappers around Werkzeug to pass some Flask-specific values.

cache_timeout is renamed to max_age. SEND_FILE_MAX_AGE_DEFAULT,
app.send_file_max_age_default, and app.get_send_file_max_age defaults
to None. This tells the browser to use conditional requests rather than
a 12 hour cache.

attachment_filename is renamed to download_name, and is always sent if
a name is known.

Deprecate helpers.safe_join in favor of werkzeug.utils.safe_join.

Removed most of the send_file tests, they're tested in Werkzeug.

In the file upload example, renamed the uploaded_file view to
download_file to avoid a common source of confusion.
2020-11-05 09:27:52 -08:00
Mathurshan Vimalesvaran 22987b6817
include samesite and secure when removing session cookie (#3726) 2020-11-04 18:16:05 -08:00
David Lord 7a444c5dab
update tests for new werkzeug client (#3827)
Flask's client.open mirrors Werkzeug's for processing an existing
environ.

Always test with latest code for other Pallets projects. This will
be changed back once the new versions are released.
2020-11-04 18:00:21 -08:00
David Lord 373f0dd82e
update requirements (#3823) 2020-11-01 05:30:02 -08:00
David Lord 6def8a4a48
test json.dumps for object with __html__ method 2020-10-31 20:18:25 -07:00
David Lord a0e2aca770
move json tests to separate file 2020-10-31 20:16:24 -07:00
Paul Sanders 8c6baeedab
parametrize some tests (#3786) 2020-10-11 19:16:17 -07:00
Bogdan Opanchuk 8efea0ccbb
Break reference cycle created by default in Flask instances.
Flask instances with static folders were creating a reference cycle
via their "static" view function (which held a strong reference back
to the Flask instance to call its `send_static_file` method). This
prevented CPython from freeing the memory for a Flask instance
when all external references to it were released.

Now use a weakref for the back reference to avoid this.

Co-authored-by: Joshua Bronson <jab@users.noreply.github.com>
2020-10-03 10:05:05 -04:00
David Lord 253570784c
cleaner message when CLI can't load app
When loading the app fails for the --help command, only the error
message is shown, then the help text. The full traceback is shown for
other exceptions. Also show the message when loading fails while
getting a command, instead of only "command not found". The error
message goes to stderr to match other error behavior, and is in red
with an extra newline to make it more obvious next to the help text.

Also fixes an issue with the test_apps fixture that caused an imported
app to still be importable after the test was over and the path was
reset. Now the module cache is reset as well.
2020-07-30 18:36:55 -07:00
David Lord 37551e6798
Merge pull request #3699 from MartinThoma/style
remove unnecessary docstrings from tests
2020-07-28 19:44:23 -07:00
Martin Thoma 75a9b74650
DOC: Remove unnecessary docstrings 2020-07-26 15:47:12 +02:00
Christopher Nguyen 7b09a0904c
change make_response to use headers.update 2020-07-23 16:53:39 -07:00
Joshua Bronson a40c381ffd
Merge pull request #3560 from greyli/fix-env-chdir
Stop change CWD to .env/.flaskenv location
2020-07-18 13:14:09 -04:00
Joshua Bronson b724832872 Cherry-pick 7ba35c4 from master (support pathlib.Path for static_folder) 2020-07-06 13:47:57 -04:00
Joshua Bronson 7ba35c4d4f Restore support for using pathlib.Path for static_folder.
* No longer causes AttributeError: 'PosixPath' object has no
  attribute 'rstrip'.

* This was broken by e6178fe489
  which was released in 1.1.2.

* Add a regression test that now passes.

See #3557.
2020-07-06 08:55:19 -04:00
Grey Li 84cbfc0698 Stop change CWD to .env/.flaskenv location 2020-07-05 09:37:03 +08:00
jackwardell 846ee2c62e
add assert message for errorhandler exception type 2020-04-16 10:49:42 -07:00
David Lord ff2f71379b
use ast to parse FLASK_APP
enables keyword arguments to factory functions
2020-04-07 17:54:51 -07:00
David Lord fcac7f11cf
deprecate passing script_info to factory 2020-04-07 15:54:36 -07:00
David Lord 8b5f760b72
deprecate JSON encoding options
make consistent with built-in json module
2020-04-07 12:32:27 -07:00
David Lord c43edfc7c0
remove simplejson
- remove encoding detection backport, json.loads supports it directly
- use str.translate instead of multiple str.replace
2020-04-07 09:55:39 -07:00
David Lord f2f027d1fb
remove unused module docstrings 2020-04-04 12:28:08 -07:00
David Lord 2ae740dd49
f-strings everywhere 2020-04-04 12:10:00 -07:00
David Lord 524fd0bc8c
apply pyupgrade 2020-04-04 12:10:00 -07:00
David Lord 57d628ca74
remove more compat code 2020-04-04 12:10:00 -07:00
David Lord 662c245795
remove _compat module 2020-04-04 12:10:00 -07:00
David Lord 1263d3bd14
remove deprecated code 2020-04-04 12:10:00 -07:00
David Lord a0a61acdec
drop support for Python 2.7 and 3.5 2020-04-04 12:09:55 -07:00
David Lord 64ba43411f
Merge remote-tracking branch 'origin/1.1.x' 2020-02-15 10:40:32 -08:00
frostming d4076cf07c
strip the ending slash for static_url_path 2020-02-10 18:19:25 -08:00
David Lord bcde664f9a
cli checks for cryptography library 2020-02-10 17:34:19 -08:00
Marc Hernandez Cabot 5da342e4dd
fix docstring and remove redundant parentheses 2020-02-10 17:03:52 -08:00
raymond-devries 900fa2f795 Feature request #3445. 2020-02-10 13:09:53 -08:00
David Lord 0834da832a
Merge branch '1.1.x' 2020-02-10 10:16:20 -08:00
David Lord 63b40254e9
xfail __main__ instance test interacting with tox 2020-02-10 10:16:08 -08:00
Grey Li ef434ea998
Replace old pocoo links everywhere
pocco.org -> palletsprojects.com
2019-11-19 09:32:35 -08:00
David Lord 980168d084
send_file doesn't allow StringIO 2019-11-19 08:52:12 -08:00
David Lord a83d6d2528
Merge remote-tracking branch 'origin/1.1.x' 2019-11-18 17:54:20 -08:00
Fernanda Guimarães c367a86cc5 Test test_send_from_directory_bad_request no longer fails in Python 3.8. 2019-10-28 21:37:25 -03:00
pgjones 829aa65e64
Support loading configuration from text files
TOML is a very popular format now, and is taking hold in the Python
ecosystem via pyproject.toml (among others). This allows toml config
files via,

    app.config.from_file("config.toml", toml.loads)

it also allows for any other file format whereby there is a loader
that takes a string and returns a mapping.
2019-10-18 09:15:47 -07:00
Doron Horwitz 0c0b31a789
get_cookie_name in SessionInterface for easier overriding in SecureCookieSessionInterface 2019-10-12 19:12:27 -07:00
David Lord 1617202d91
restore and deprecate json_available 2019-07-08 10:26:12 -07:00
David Lord b08e35e4ab
show warning for old logger config 2019-07-02 11:39:00 -07:00
David Lord df470aecb9
use app.name as app.logger name 2019-07-01 14:56:18 -07:00
David Lord b05a685a03
Merge branch '1.0.x' 2019-07-01 10:54:31 -07:00
Anthony Sottile a5ecdfa7a5
Fixes for PEP451 import loaders and pytest 5.x
- pytest 5.x drops python2 compatibility and therefore only implements PEP 451
- pytest 5.x made the repr of `ExcInfo` less confusing (fixed tests depending
  on the old format)
2019-07-01 10:43:06 -07:00
David Lord afd6250bab
Merge branch '1.0.x' 2019-07-01 09:52:06 -07:00
Anthony Sottile ac302fb607 Make the changelog UTF-8 compatible 2019-07-01 07:36:20 -07:00
David Lord 54cbb4e642
send_file quotes ":/" in UTF-8 filename 2019-06-27 07:55:22 -07:00
David Lord 1351d0a565
Merge branch '1.0.x' 2019-06-23 16:57:52 -07:00
David Lord e666f7a69c
standardize license and copyright 2019-06-22 13:09:09 -07:00
David Lord 9054f6d639
always pass InternalServerError instance to 500 handler 2019-06-19 14:52:25 -07:00
David Lord c65863912b
move url matching after opening session 2019-06-13 12:40:01 -07:00
Elad Moshe 1ff98a2d21
wait until app ctx is ready before matching url
`RequestContext.match_request` is moved from `__init__` to `push`. This
causes matching to happen later, when the app context is available.
This enables URL converters that use things such as the database.
2019-06-13 08:32:23 -07:00
David Lord 29111a3259
Merge branch '1.0.x' 2019-06-12 10:41:11 -07:00
David Lord dbd4520ccb
fix tests failing with server name warnings
After pallets/werkzeug#1577, mismatched configured and real server
names will show a warning in addition to raising 404. This caused
tests that did this deliberately to fail.

This patch removes the pytest fixture we were using to fail on
warnings, instead using the standard `-Werror` option. This speeds
up the tests by ~3x.
2019-06-10 14:05:33 -07:00
David Lord 53c893b646
fix string concats left over by black 2019-06-01 09:22:20 -07:00
David Lord 43483683b2
apply reorder-python-imports pre-commit config 2019-06-01 09:07:20 -07:00
Jon S. Stumpf b46f5942a5
address flake8 issues 2019-06-01 06:31:35 -07:00
Jon S. Stumpf 549fed29ea
add pre-commit config for flake8 2019-06-01 09:13:46 -04:00
cslecrone 1718f1934c
don't require ssl module for flask cli 2019-05-31 17:27:52 -04:00
Daniel Pope c7f56c5a55 Create json_dumps() method on new EnvironBuilder 2019-05-31 18:05:25 +01:00
Daniel Pope 976dfedaa9 Convert make_test_environ_builder into class (fixes #3207) 2019-05-31 18:05:25 +01:00
David Lord 91e53da054
Merge pull request #3236 from lordmauve/no-cligroup-empty
Do not register empty CLI groups from Blueprint
2019-05-31 13:05:00 -04:00
John Zeringue 8bb7185284 Better error message when view return type is not supported
Before, returning a `bool` from a route caused the error

```
[2019-05-31 10:08:42,216] ERROR in app: Exception on / [GET]
Traceback (most recent call last):
  File "/Users/johnzeringue/Documents/ts-open/flask/flask/app.py", line 2070, in make_response
    rv = self.response_class.force_type(rv, request.environ)
  File "/Users/johnzeringue/Documents/ts-open/flask/env/lib/python3.7/site-packages/werkzeug/wrappers/base_response.py", line 269, in force_type
    response = BaseResponse(*_run_wsgi_app(response, environ))
  File "/Users/johnzeringue/Documents/ts-open/flask/env/lib/python3.7/site-packages/werkzeug/wrappers/base_response.py", line 26, in _run_wsgi_app
    return _run_wsgi_app(*args)
  File "/Users/johnzeringue/Documents/ts-open/flask/env/lib/python3.7/site-packages/werkzeug/test.py", line 1119, in run_wsgi_app
    app_rv = app(environ, start_response)
TypeError: 'bool' object is not callable

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/johnzeringue/Documents/ts-open/flask/flask/app.py", line 2393, in wsgi_app
    response = self.full_dispatch_request()
  File "/Users/johnzeringue/Documents/ts-open/flask/flask/app.py", line 1906, in full_dispatch_request
    return self.finalize_request(rv)
  File "/Users/johnzeringue/Documents/ts-open/flask/flask/app.py", line 1921, in finalize_request
    response = self.make_response(rv)
  File "/Users/johnzeringue/Documents/ts-open/flask/flask/app.py", line 2078, in make_response
    reraise(TypeError, new_error, sys.exc_info()[2])
  File "/Users/johnzeringue/Documents/ts-open/flask/flask/_compat.py", line 39, in reraise
    raise value.with_traceback(tb)
  File "/Users/johnzeringue/Documents/ts-open/flask/flask/app.py", line 2070, in make_response
    rv = self.response_class.force_type(rv, request.environ)
  File "/Users/johnzeringue/Documents/ts-open/flask/env/lib/python3.7/site-packages/werkzeug/wrappers/base_response.py", line 269, in force_type
    response = BaseResponse(*_run_wsgi_app(response, environ))
  File "/Users/johnzeringue/Documents/ts-open/flask/env/lib/python3.7/site-packages/werkzeug/wrappers/base_response.py", line 26, in _run_wsgi_app
    return _run_wsgi_app(*args)
  File "/Users/johnzeringue/Documents/ts-open/flask/env/lib/python3.7/site-packages/werkzeug/test.py", line 1119, in run_wsgi_app
    app_rv = app(environ, start_response)
TypeError: 'bool' object is not callable
The view function did not return a valid response. The return type must be a string, tuple, Response instance, or WSGI callable, but it was a bool.
```

Now, it returns the more readable

```
[2019-05-31 10:36:19,500] ERROR in app: Exception on / [GET]
Traceback (most recent call last):
  File "/Users/johnzeringue/Documents/ts-open/flask/flask/app.py", line 2400, in wsgi_app
    response = self.full_dispatch_request()
  File "/Users/johnzeringue/Documents/ts-open/flask/flask/app.py", line 1907, in full_dispatch_request
    return self.finalize_request(rv)
  File "/Users/johnzeringue/Documents/ts-open/flask/flask/app.py", line 1922, in finalize_request
    response = self.make_response(rv)
  File "/Users/johnzeringue/Documents/ts-open/flask/flask/app.py", line 2085, in make_response
    " {rv.__class__.__name__}.".format(rv=rv))
TypeError: The view function did not return a valid response. The return type must be a string, dict, tuple, Response instance, or WSGI callable, but it was a bool.
```

Fixes #3214
2019-05-31 11:58:49 -04:00
Daniel Pope f25b5000fd Do not register empty CLI groups from Blueprint
(Fixes #3224)
2019-05-31 16:49:01 +01:00
Daniel Pope a5ff3cd01b Fix style issues on master using Black 2019-05-31 11:57:28 +01:00
Fantix King a71c167836
fix teardown bug in FlaskClient
* Fixes pytest-dev/pytest-flask#42
2019-05-25 14:03:28 -07:00
David Lord ed9ab2d3b6
strip static url trailing slash at assignment 2019-05-25 11:18:40 -07:00
Pete Beardmore a12bf290da
fix 'static_url_path' defaulting for empty paths
-prefix a path delimiter iff there's a path to delimit
-ensures a valid default static route rule is created on application
intialisation for the case 'static_folder=""' and implicit
'static_url_path'
2019-05-25 07:03:36 -07:00
Anthony Plunkett ec1ccd7530
Add Blueprint level cli command registration
Implements #1357.
Adds ability to register click cli commands onto blueprint.
2019-05-24 14:43:29 -07:00
pgjones 7bf8366970
Allow dictionary return values as JSON
This supports an increasingly common usecase whereby JSON is the
primary response (rather than a templated string). Given Flask has a
short syntax for HTML reponses, it seems fitting that it should also
do so for JSON responses. In practice it allows,

     @app.route("/")
     def index():
         return {
             "api_stuff": "values",
         }
2019-05-24 09:48:55 -07:00
Adarsh Sharma db8cb31f2b
Fix #2937: Ensure the consistency in load_dotenv's return type 2019-05-19 11:58:39 -07:00
vorelq e1cc16f8be
Fix 0 port value being overriden by default
By explicitly comparing port value with None,
instead of using its bool() value.
2019-05-19 11:36:47 -07:00
Eruvanos 6af14f058b
support dataclass in JSONEncoder 2019-05-18 21:37:54 -07:00
Frankie Liu 2039e2e3b6
Remove ending slash from static_url_path 2019-05-18 21:23:14 -07:00
EtiennePelletier 8590d65a57
Use Werkzeug's JSONMixin class and update tests
Flask's JSONMixin class was moved to Werkzeug>=0.15

Co-authored-by: Jeffrey Eliasen <jeff@jke.net>
2019-05-18 20:57:26 -07:00
LeeW 1f3923a999
Inherit "methods" in MethodView
* Current behavior: If a base class inherits MethodView and child class
  inherits without overwriting "methods". The "methods" defined in base
  class would be ignored
* Fix: Inherit all the "methods" defined in base classes if "methods"
  variable is not overwritten
2019-05-17 13:57:06 -07:00
David Lord 6f703a564c
clean up open_resource and tests 2019-05-17 13:23:27 -07:00
icreatedanaccount ad709be46e
Allow mode='rt' on open_resource() helper 2019-05-17 13:22:13 -07:00
David Lord 05a4e15ee4
Merge branch '1.0.x' 2019-05-17 11:13:08 -07:00
David Lord a4f0f19796
don't push app context for test client json 2019-05-17 09:00:08 -07:00
David Baumgold 025589ee76 Reformat with black
https://github.com/python/black
2019-05-06 16:28:58 -04:00
David Lord a74864ec22
Merge remote-tracking branch 'origin/1.0-maintenance' 2019-01-07 10:00:10 -08:00
David Lord 662ce2151d
add changelog for GH-2986 2019-01-07 09:52:54 -08:00
Jimmy Jia b92b2e6c74
Do not handle RoutingExceptions with app error handlers 2019-01-07 09:01:37 -08:00
garenchan 40118e785f
Make sure the attachment filename is text type.
If attachment filename is bytes type and contains non-ascii coded bytes,
then the following ASCII encoding process will trigger
UnicodeDecodeError exception.

Fix issue #2933.
2019-01-07 07:17:33 -08:00
David Lord 366f3f49af
add changelog for GH-2957 2019-01-07 06:56:20 -08:00
Ignasi Bosch b570bf699c
Allow partial content on bytesio 2019-01-07 06:17:36 -08:00
David Lord 4f3dbb3f3b
Merge branch '1.0-maintenance' 2019-01-06 16:33:17 -08:00
David Lord a0ccc47780
clean up flask --version code 2019-01-06 16:24:05 -08:00
Matt Robenolt 25de45cbb6
Add support for PathLike objects in static file helpers
See: https://www.python.org/dev/peps/pep-0519/

This is mostly encountered with pathlib in python 3, but this API
suggests any PathLike object can be treated like a filepath with
`__fspath__` function.
2019-01-05 15:23:47 -08:00
David Lord f7d50d4b67
Merge branch '1.0-maintenance' 2019-01-05 15:12:17 -08:00
David Lord 49efc44233
clear KeyError in production for Werkzeug 0.15 2019-01-05 12:49:59 -08:00
Jarek Piórkowski 9b0bd91195 Correct tests
We've discovered that passing Unicode in Host actually works, except for
test client limitations on Python 2 - and the only things that don't
work are non-printable characters.
2018-11-13 13:09:16 -05:00
Jarek Piórkowski ed9775fb77 Handle errors during create_url_adapter
If create_url_adapter raises (which it can if werkzeug cannot bind
environment, for example on non-ASCII Host header), we handle it as
other routing exceptions rather than raising through.

ref https://github.com/pallets/werkzeug/issues/640
2018-11-12 16:59:09 -05:00
Dave Chevell e08bcf9f97 Fix #2935: Copy current session object in copy_current_request_context (#2936)
Add session to RequestContext.copy()
2018-11-03 20:32:24 -07:00
garenchan c38499bbf2 ignore colon with slash when split app_import_path
Flask currently supports importing app through a combination of module
path and app variable name, such as '/usr/app.py:my_app'. When the
module path contains a colon, it will conflict with this import way and
a `flask.cli.NoAppException` will be raised.

A file path on a Windows system may contain a colon followed by a slash.
So we solved this problem on Windows by ignoring the colon followed by a
slash when we split app_import_path.

Fix issue #2961.
2018-10-24 23:47:41 +08:00
ThiefMaster 161c43649d Merge branch '1.0-maintenance' 2018-06-14 13:31:40 +02:00
ThiefMaster 50227f0954 Add option to not overwrite debug flag in cli
This is mainly intended for custom CLIs that may load a config file
which already sets the debug flag and does not make use of the `FLASK_*`
env vars at all.
2018-06-14 13:25:05 +02:00
Grey Li 4025e27b57 Add test for routes command when no routes registered 2018-05-31 11:43:51 +08:00
Dilan Coss 8fa3ed13bf details fixed 2018-05-29 09:51:08 -06:00
Dilan Coss 8cdd01ea5d Test added for _AppCtxGlobals __repr__ method 2018-05-28 23:49:06 -06:00
David Lord b51ab3ff2c
encode filenames as ascii instead of latin-1
latin-1 is allowed by pep3333, but that breaks gunicorn
2018-05-28 06:36:47 -07:00
Briehan Lombaard a913b4dafd
SSLContext was added in Python 2.7.9 2018-05-17 06:18:42 -07:00
David Lord b21b4d1608
add more merge cases 2018-05-01 13:29:48 -07:00
Hsiaoming Yang f7a3bdc6db
Fix blueprint route for "" 2018-05-01 14:35:55 +09:00
David Lord 5965cb7e1c
rename to FLASK_SKIP_DOTENV, add docs, test 2018-04-29 14:20:17 -07:00
David Lord 4c8ec8f555
Merge pull request #2739 from pallets/2735-abort-debug
Only trap key errors by default in debug, not all BadRequest errors
2018-04-28 07:01:42 -07:00
David Lord b573a86977
trap key errors in debug, not all 400 errors 2018-04-28 06:51:08 -07:00
David Lord 4d0cdf95e6
merge slashes between blueprint prefix and rule 2018-04-27 12:40:06 -07:00
ThiefMaster 6663bf1f7d Fix registering partials as view functions 2018-04-27 13:44:07 +02:00
Nick Pope fc6a1d9354 Fix default index for TaggedJSONSerializer.register()
Change the default value of ``index`` to ``None`` in ``register()`` so
that it is possible to insert a new tag as the penultimate item in the
order list.
2018-04-19 14:16:11 +01:00
David Lord 1ed756a523
add Response.max_cookie_size config 2018-04-10 11:17:18 -07:00
David Lord ab4142215d
detect UTF encodings when loading json 2018-04-10 09:34:59 -07:00
fphonor 171eb28c95
get_json separate cache depending on silent arg 2018-04-09 02:52:40 -07:00
David Lord 5f42989ce3
don't use Flask(__name__) in conftest 2018-02-28 06:50:49 -08:00
David Lord 401423df06
only strip one slash when registering blueprint
add test and changelog
2018-02-23 15:47:06 -08:00
David Lord 82f0d120de
use subdomain arg in url_map.bind_to_environ
rename new subdomain test, parametrize
test allowing subdomains as well as ips
add subdomain_matching param to docs
add some references to docs
add version changed to create_url_adapter
2018-02-23 08:39:31 -08:00
Armin Ronacher 8cec2010c0
Do not enable subdomain matching by default
Updated tests for new subdomain matching
Added a test to validate matching behavior
2018-02-23 07:53:27 -08:00
David Lord cf5525f98a
add test_cli_runner for testing app.cli commands 2018-02-19 15:34:46 -08:00
David Lord 310fbfcf64
revert copyright year to project start
add copyright header to files
2018-02-08 12:43:30 -08:00
David Lord 03a2996bb8
Merge pull request #2530 from pallets/feature/factory-detection
Improved bad factory error handling
2018-01-28 11:27:07 -08:00
David Lord e21abd9da5
Merge pull request #2607 from FadhelC/SameSite-cookie-feature
Added support for cookie SameSite attribute
2018-01-23 15:20:16 -08:00
David Lord 382b13581e
clean up samesite docs 2018-01-23 15:11:50 -08:00
David Lord 2beedabaaf
add HTTPS support for flask run command 2018-01-23 10:03:53 -08:00