Commit graph

487 commits

Author SHA1 Message Date
Grey Li
66a28f0f28 Replace old pocoo links everywhere
pocco.org -> palletsprojects.com
2019-11-19 09:32:35 -08:00
David Lord
46c3d4656d send_file doesn't allow StringIO 2019-11-19 08:52:12 -08:00
David Lord
3996b7842e Merge remote-tracking branch 'origin/1.1.x' 2019-11-18 17:54:20 -08:00
Fernanda Guimarães
7806be9784 Test test_send_from_directory_bad_request no longer fails in Python 3.8. 2019-10-28 21:37:25 -03:00
pgjones
35627192e7 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
940fa38c28 get_cookie_name in SessionInterface for easier overriding in SecureCookieSessionInterface 2019-10-12 19:12:27 -07:00
David Lord
f19014c7a1 restore and deprecate json_available 2019-07-08 10:26:12 -07:00
David Lord
e8b8fcbfd4 show warning for old logger config 2019-07-02 11:39:00 -07:00
David Lord
ba1fcd1887 use app.name as app.logger name 2019-07-01 14:56:18 -07:00
David Lord
1ee9405ff3 Merge branch '1.0.x' 2019-07-01 10:54:31 -07:00
Anthony Sottile
f65c6d3860 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
7b4f294465 Merge branch '1.0.x' 2019-07-01 09:52:06 -07:00
Anthony Sottile
8c68190ed0 Make the changelog UTF-8 compatible 2019-07-01 07:36:20 -07:00
David Lord
158db956a3 send_file quotes ":/" in UTF-8 filename 2019-06-27 07:55:22 -07:00
David Lord
ff0c92a1c7 Merge branch '1.0.x' 2019-06-23 16:57:52 -07:00
David Lord
e066e9f9e3 standardize license and copyright 2019-06-22 13:09:09 -07:00
David Lord
6b4ca46a4a always pass InternalServerError instance to 500 handler 2019-06-19 14:52:25 -07:00
David Lord
4d904d4f29 move url matching after opening session 2019-06-13 12:40:01 -07:00
Elad Moshe
26cde0536c 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
43f66251ad Merge branch '1.0.x' 2019-06-12 10:41:11 -07:00
David Lord
090bc4470e 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
2cf5d51523 fix string concats left over by black 2019-06-01 09:22:20 -07:00
David Lord
e66fe2e8e7 apply reorder-python-imports pre-commit config 2019-06-01 09:07:20 -07:00
Jon S. Stumpf
4dc9c68d19 address flake8 issues 2019-06-01 06:31:35 -07:00
Jon S. Stumpf
8577b347a7 add pre-commit config for flake8 2019-06-01 09:13:46 -04:00
cslecrone
f7d690e474 don't require ssl module for flask cli 2019-05-31 17:27:52 -04:00
Daniel Pope
39df2b7dc3 Create json_dumps() method on new EnvironBuilder 2019-05-31 18:05:25 +01:00
Daniel Pope
4d595a74a2 Convert make_test_environ_builder into class (fixes #3207) 2019-05-31 18:05:25 +01:00
David Lord
36ed441533 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
d610a559d1 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
ecdb6e98ae Do not register empty CLI groups from Blueprint
(Fixes #3224)
2019-05-31 16:49:01 +01:00
Daniel Pope
ad9807891d Fix style issues on master using Black 2019-05-31 11:57:28 +01:00
Fantix King
9eadc5434b fix teardown bug in FlaskClient
* Fixes pytest-dev/pytest-flask#42
2019-05-25 14:03:28 -07:00
David Lord
cfedcd308e strip static url trailing slash at assignment 2019-05-25 11:18:40 -07:00
Pete Beardmore
37b5569e92 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
cc2580af09 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
9e0bd76d2a 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
c884f6ec19 Fix #2937: Ensure the consistency in load_dotenv's return type 2019-05-19 11:58:39 -07:00
vorelq
c33ec49db6 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
36362454c3 support dataclass in JSONEncoder 2019-05-18 21:37:54 -07:00
Frankie Liu
c7432f50cb Remove ending slash from static_url_path 2019-05-18 21:23:14 -07:00
EtiennePelletier
1a9616d581 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
43fe5f7d0b 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
371d1ab40d clean up open_resource and tests 2019-05-17 13:23:27 -07:00
icreatedanaccount
07a177043f Allow mode='rt' on open_resource() helper 2019-05-17 13:22:13 -07:00
David Lord
d37b992a54 Merge branch '1.0.x' 2019-05-17 11:13:08 -07:00
David Lord
8a431d4342 don't push app context for test client json 2019-05-17 09:00:08 -07:00
David Baumgold
85ce588b3b Reformat with black
https://github.com/python/black
2019-05-06 16:28:58 -04:00
David Lord
39e9ebaaee Merge remote-tracking branch 'origin/1.0-maintenance' 2019-01-07 10:00:10 -08:00
David Lord
83fb602af7 add changelog for GH-2986 2019-01-07 09:52:54 -08:00