Commit graph

105 commits

Author SHA1 Message Date
David Lord
3dfc12e8d8
only extend on first registration 2021-03-10 10:51:06 -08:00
David Lord
ef52e3e4a3
remove redundant _register_error_handler 2021-03-10 10:38:17 -08:00
David Lord
25ab05e6a2
remove old note about InternalServerError 2021-03-10 10:38:16 -08:00
David Lord
7029674775
rewrite Scaffold docs 2021-03-10 10:38:16 -08:00
David Lord
9f7c602a84
move _PackageBoundObject into Scaffold 2021-03-10 10:38:13 -08:00
Grey Li
33145c3699 Set default encoding to UTF-8 for load_dotenv 2021-03-10 21:40:29 +08:00
pgjones
83d358d2c4
remove _blueprint_order, dicts are ordered
This code originates from supporting Python 2.4. Dicts are ordered in
supported Pythons as of 3.6. An OrderedDict could be used to indicate
that order matters, but is not since we don't rely on the implementation
differences.
2021-03-08 09:58:12 -08:00
pgjones
fd62210f58
Utilise defaultdicts
This code originates from the Python 2.4 supporting version of Flask,
with defaultdicts being added in 2.5. Using defaultdict makes the
intentional usage clearer, and slightly simplifies the code.
2021-03-08 09:58:12 -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
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
David Lord
81ba6c24ef
remove Jinja 'autoescape' and 'with' extensions 2021-02-01 19:14:58 -08:00
David Lord
055cdc2625
click detects program name when run as module 2021-01-29 11:29:36 -08:00
David Lord
64206c13c2
simplify InternalServerError.original_exception 2021-01-29 11:26:17 -08:00
David Lord
eb42655c46
simplify BadRequestKeyError.show_exception 2021-01-29 11:03:33 -08:00
David Lord
14f56363a4
rename send_file add_etags to etag 2021-01-29 10:52:48 -08:00
David Lord
1936ca8a2e
remove BaseRequest and BaseResponse 2021-01-29 10:52:48 -08:00
David Lord
fdba0d2526
remove JSONMixin 2021-01-29 10:52:48 -08:00
Grey Li
2fab8a31ae Fix broken func directives in docstrings 2021-01-04 10:32:01 +08:00
Grey Li
7d2ba3e1fc Merge remote-tracking branch 'origin/1.1.x' 2021-01-04 10:14:36 +08:00
huimingz
aff21fd8bc Document parameter description error
The loads function has the wrong 'kwargs' parameter description
2021-01-04 09:45:01 +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
1c6dc15420
fix response bases order 2020-10-31 19:19:11 -07:00
Sebastian Höffner
5d60cce242
Updating external_url_handler example to Python 3 (#3816) 2020-10-29 09:33:20 -07:00
David Lord
967b235035
Merge pull request #3728 from nphilipp/master--discover-app-factory-deterministically
Discover app factory deterministically
2020-10-15 14:01:14 -07:00
Matěj Volf
bdf7083cfd
refer to encoder instead of decoder 2020-10-07 08:06:29 -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
ongopongo
5bfe236fb5
fix typo in flask shell help (#3744) 2020-08-26 09:20:21 -07:00
WolframAlph
1f1b65a625 fixed #3738 typo in src/flask/blueprints.py 2020-08-23 08:56:24 +02:00
Nils Philippsen
cf3089a8f8 Discover app factory deterministically
Commit 2ae740dd49 probably inadvertently
changed to iterate over a set of "create_app", "make_app" to discover
application factory functions. As sets don't guarantee order,
differences in the implementation of the type can make it
non-deterministic which factory function is used if a project implements
both. Revert to using a tuple.

Signed-off-by: Nils Philippsen <nils@redhat.com>
2020-08-13 10:44:43 +02:00
yk396
b146a13f63
extract common Flask/Blueprint API to Scaffold base class
Co-authored-by: Chris Nguyen <chrisngyn99@gmail.com>
2020-08-01 07:45:58 -07: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
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
Armin Ronacher
4a1acc8b5f Some small doc fixes 2020-07-08 15:53:43 +02: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
756902cca1
update json docs 2020-04-07 13:37:14 -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
024f0d384c
move package metadata to setup.cfg 2020-04-04 14:50:21 -07:00
David Lord
171aabc87d
remove unused ref directives
replace page refs with doc directives
2020-04-04 12:57:14 -07:00